标签:链接 匹配 encoding rip http else single pack ==
‘?‘ Matches any single character.
‘*‘ Matches any sequence of characters (including the empty sequence).
字符串匹配问题。package leetcode_50; /*** * * @author pengfei_zheng * 字符串匹配问题 */ public class Solution44 { public boolean isMatch(String s, String p) { int sp = 0, pp = 0, match = 0, starIdx = -1; while (sp < s.length()){ if (pp < p.length() && (p.charAt(pp) == ‘?‘ || s.charAt(sp) == p.charAt(pp))){ sp++; pp++; } else if (pp < p.length() && p.charAt(pp) == ‘*‘){ starIdx = pp; match = sp; pp++; } else if (starIdx != -1){ pp = starIdx + 1; match++; sp = match; } else return false; } while (pp < p.length() && p.charAt(pp) == ‘*‘) pp++; return pp == p.length(); } }
LeetCode 44 Wildcard Matching(字符串匹配问题)
标签:链接 匹配 encoding rip http else single pack ==
原文地址:http://www.cnblogs.com/zpfbuaa/p/6542144.html