leetcode - Wildcard Matching
2013-12-11 11:24
399 查看
// token form http://blog.csdn.net/sunbaigui/article/details/8981369 // still need more check class Solution { //if strlen is used, then it will be TLE //iteration based solution public: bool isMatch(const char *s, const char *p) { // Start typing your C/C++ solution below // DO NOT write int main() function //int len1 = strlen(s); //int len2 = strlen(p); bool star = false; const char* starPtr = NULL; const char* savePtr = NULL; while(*s != '\0') { if(*p == '?') s++, p++; else if(*p == '*') { while(*p == '*') p++; p--; starPtr = p; p++; savePtr = s; star = true; } else { if(*s == *p) s++, p++; else { if(star == true) s = ++savePtr, p = starPtr+1;//depend on star else return false; } } } while(*p == '*') p++; return (*s == '\0' && *p == '\0'); } };
相关文章推荐
- leetcode-44. Wildcard Matching
- leetcode 44. Wildcard Matching
- leetcode:Wildcard Matching
- LeetCode 109 Wildcard Matching
- [LeetCode] Wildcard Matching
- Leetcode 44. Wildcard Matching
- leetcode--WildcardMatching
- leetcode-44. Wildcard Matching
- leetcode - Wildcard Matching
- [leetcode]Wildcard Matching
- LeetCode刷题笔录Wildcard Matching
- [LeetCode] Wildcard Matching
- LeetCode 44. Wildcard Matching
- [leetcode] Wildcard Matching
- 个人记录-LeetCode 44. Wildcard Matching
- leetcode Wildcard Matching
- [LeetCode] 44. Wildcard Matching
- LeetCode-Wildcard Matching
- Leetcode-44. Wildcard Matching
- leetcode: Wildcard Matching