Wildcard Matching
来源:互联网 发布:ipad怎么看淘宝直播间 编辑:程序博客网 时间:2024/06/06 00:35
Implement wildcard pattern matching with support for '?'
and '*'
.
'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototype should be:bool isMatch(const char *s, const char *p)Some examples:isMatch("aa","a") → falseisMatch("aa","aa") → trueisMatch("aaa","aa") → falseisMatch("aa", "*") → trueisMatch("aa", "a*") → trueisMatch("ab", "?*") → trueisMatch("aab", "c*a*b") → false
class Solution {public: bool isMatch(string s, string p) { int ssize = s.size(); int psize = p.size(); int i = 0, j = 0, pi = 0, pj = psize; while (i < ssize) { if (j < psize && (s[i] == p[j] || p[j] == '?')) { i++; j++; continue; } else if (j < psize && p[j] == '*') { pj = j++; pi = i; continue; } else if (pj < psize) { j = pj + 1; i = ++pi; continue; } return false; } while (j < psize && p[j] == '*') { j++; } return j == psize; }};
0 0
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- Wildcard Matching
- 绑定focus事件的函数里绑定键盘事件造成的冲突?错误?
- 深入学习Service
- 持久化对象的状态
- Android中View绘制流程以及invalidate()等相关方法分析
- Android中View(视图)绘制不同状态背景图片原理深入分析以及StateListDrawable使用详解
- Wildcard Matching
- Fake Numbers
- Android中将布局文件/View添加至窗口过程分析 ---- 从setContentView()谈起
- iphone"此证书是由未知颁发机构签名的"的解决办法
- 生成不了p12证书的缘故
- the Zeros and Ones
- 假如今天是我生命中的最后一天(转摘)
- respondsToSelector的相关使用
- android背景选择器selector用法汇总