[LeetCode]--Wildcard Matching

[LeetCode]--Wildcard Matching
public class Solution {
   public boolean isMatch(String s, String p) {
        int sLen = s.length(), pLen = p.length();
        int i = 0, j = 0;
        int ss = 0, starP = -1;
        while (i < sLen) {
            
            while(j < pLen && p.charAt(j) == ‘*‘){
                starP = j++;
                ss = i;
            }
            
            if((j == pLen) || (s.charAt(i) != p.charAt(j) && p.charAt(j) != ‘?‘)){
                if(starP < 0){
                    return false;
                } else {
                    j = starP + 1;
                    i = ++ss;
                }
            } else{
                i++;
                j++;
            }
            
            
        }
        
        
        while (j < pLen && p.charAt(j) == ‘*‘) {
            j++;
        }
        
        return j == pLen;
    }
}
[LeetCode]--Wildcard Matching

[LeetCode]--Wildcard Matching

上一篇:选择一个图片文件,并且用PictureBox表示在Form上


下一篇:soap和http(转)