LeetCode::Wildcard Matching
来源:互联网 发布:java字符串方法 编辑:程序博客网 时间:2024/05/14 19:28
https://oj.leetcode.com/problems/wildcard-matching/
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(const char *s, const char *p) { const char* stemp = nullptr; const char* asterisk = nullptr; while(*s != '\0') { if (*p == *s || *p == '?') { s++; p++; continue; } if (*p == '*') { stemp = s; asterisk = p; p++; continue; } if (asterisk != nullptr) { s = ++stemp; p = asterisk + 1; continue; } return false; } while (*p == '*') { p++; } return *p == '\0'; }};
0 0
- LeetCode: Wildcard Matching
- LeetCode : Wildcard Matching
- [LeetCode] Wildcard Matching - Iteratively
- leetcode 83: Wildcard Matching
- [Leetcode] Wildcard Matching
- [LeetCode]Wildcard Matching
- LeetCode-Wildcard Matching
- LeetCode -- Wildcard Matching
- LeetCode | Wildcard Matching
- Leetcode: Wildcard Matching
- Leetcode:Wildcard Matching
- LeetCode题解:Wildcard Matching
- LeetCode Wildcard Matching
- [Leetcode] Wildcard Matching (Java)
- LeetCode OJ:Wildcard Matching
- Leetcode: Wildcard Matching
- Wildcard Matching -- LeetCode
- [LeetCode] Wildcard Matching
- 发生锁等待时,常用的解决方案
- QT安装和使用 qscintilla2 控件
- Andrew Stankevich's Contest (4) F - Think Positive 单调队列
- DirectX11 学习笔记6 - 使用D3DXMATH数学库的一个例子
- 毕业这三年(续)
- LeetCode::Wildcard Matching
- 或得不思,度娘垂青收录?
- ACdream 1430 【后缀数组+分组】
- iOS利用AFNetworking进行JSON数据解析
- Linux 限制IP——/etc/hosts.allow和/etc/hosts.deny文件
- C++ STL 容器整理
- PHP高效率写法(详解原因)
- c语言学习之day04
- 使用NPOI读取Excel数据到DataTable