leetcode 44. Wildcard Matching
来源:互联网 发布:ubuntu 运行c 编辑:程序博客网 时间:2024/06/03 10:16
leetcode 44. Wildcard Matching
这是一段拙劣的程序: Acc at the end in complexity ranking
public class Solution {public static void main(String[] arg){String a = "aa";String b = "*";Solution s = new Solution();boolean re = s.isMatch(a,b);} public int max(int a,int b){ return a>b?a:b; } public boolean isMatch(String s, String p) { int sl = s.length(); int pl = p.length(); if(sl==0){ for(int h=0;h<pl;h++){ if(p.charAt(h)!='*') return false; } return true; } if(pl==0) return false; int[][] dp = new int[sl+1][pl+1]; //pre for(int i=0;i<=sl;i++){ for(int j=0;j<=pl;j++){ dp[i][j] = -1; } } dp[0][0] = 1; for(int i=1;i<=sl;i++){ for(int j=1;j<=pl;j++){ if( p.charAt(j-1)=='*' ){ for(int k=i-1;k<=sl;k++){ dp[k][j] = max(dp[i-1][j-1],dp[k][j]); } for(int k=i;k<=sl;k++){ dp[k][j] = max(dp[i][j-1],dp[k][j]); } } if( s.charAt(i-1)==p.charAt(j-1) || p.charAt(j-1)== '?' ){ dp[i][j] = max(dp[i-1][j-1],dp[i][j]); } } } if(dp[sl][pl]==1) return true; return false; }}
0 0
- LeetCode --- 44. Wildcard Matching
- [Leetcode] 44. Wildcard Matching
- Leetcode 44. Wildcard Matching
- leetcode 44. Wildcard Matching
- Leetcode 44. Wildcard Matching
- Leetcode:44. Wildcard Matching
- LeetCode 44. Wildcard Matching
- leetcode.44. Wildcard Matching
- LeetCode 44. Wildcard Matching
- Leetcode-44. Wildcard Matching
- [LeetCode] 44. Wildcard Matching
- [leetcode] 44. Wildcard Matching
- [LeetCode]--44. Wildcard Matching
- LeetCode 44. Wildcard Matching
- leetcode 44. Wildcard Matching
- LeetCode 44. Wildcard Matching
- 44. Wildcard Matching -- LeetCode
- LeetCode 44. Wildcard Matching
- UVA 10791
- CTF-练习平台 Web writeup By Assassin [暂时完结]
- 【转载】Java中的数据存储(堆、栈、常量池)
- CN和CNTK的介绍(一)
- 写一个Tomcat+Okhttp实现的聊天websocket聊天框架(二)--完成私聊功能
- leetcode 44. Wildcard Matching
- xampp下mysql解决中文乱码问题
- cas4.2.7定制登录页面样式(并且让页面默认使用中文提示)
- 哈夫曼编码
- 简单排序算法时间空间复杂度分析及应用(1)-冒泡排序
- 线程安全
- c++指针的一些陷阱(更新ing)
- thinkphp部署到Linux后验证码功能不显示
- 类和对象的深入剖析【整理】