| 1 | class Solution { |
| 2 | public: |
| 3 | bool isMatch(string s, string p) { |
| 4 | int m = s.length(), n = p.length(); |
| 5 | int i = 0, j = 0, asterick = -1, match; |
| 6 | while (i < m) { |
| 7 | if (j < n && p[j] == '*') { |
| 8 | match = i; |
| 9 | asterick = j++; |
| 10 | } |
| 11 | else if (j < n && (s[i] == p[j] || p[j] == '?')) { |
| 12 | i++; |
| 13 | j++; |
| 14 | } |
| 15 | else if (asterick >= 0) { |
| 16 | i = ++match; |
| 17 | j = asterick + 1; |
| 18 | } |
| 19 | else return false; |
| 20 | } |
| 21 | while (j < n && p[j] == '*') j++; |
| 22 | return j == n; |
| 23 | } |
| 24 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected