wildcard-matching
来源:互联网 发布:excel大量数据统计 编辑:程序博客网 时间:2024/06/03 07:27
题目:
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”) → false
isMatch(“aa”,”aa”) → true
isMatch(“aaa”,”aa”) → false
isMatch(“aa”, “*”) → true
isMatch(“aa”, “a*”) → true
isMatch(“ab”, “?*”) → true
isMatch(“aab”, “c*a*b”) → false
程序:
class Solution{public: bool isMatch(const char *s, const char *p) { int ls = strlen(s), lp = strlen(p); vector<vector<bool> > vvb(ls + 1, vector<bool>(lp + 1, false)); vvb[0][0] = true; for(int j = 1; j <= lp; ++ j) { vvb[0][j] = vvb[0][j - 1] && '*' == p[j - 1]; for(int i = 1; i <= ls; ++ i) { if('?' == p[j - 1] || s[i - 1] == p[j - 1]) vvb[i][j] = vvb[i - 1][j - 1]; else if('*' == p[j - 1]) vvb[i][j] = vvb[i][j - 1] || vvb[i - 1][j]; } } return vvb[ls][lp]; }};
阅读全文
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
- AtCoder Grand Contest 001 E
- pycharm笔记--设置字体大小
- DOM操作动态增加表格
- springmvc处理流程
- 语义化,让你的网页更好的被搜索引擎理解
- wildcard-matching
- Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks(更快的RCNN:通过区域提议网络实现实时)
- SDUT 2116数据结构实验之链表一:顺序建立链表
- 树的遍历 已知后序,中序,求前序
- Android源码解析(1)--截屏事件流程
- 策略模式
- IDE编译器学习与实现(如C/C++)
- AJAX中使用post,get接收发送数据的区别
- 工厂模式(三)-抽象工厂模式(C++实现)