天题之Regular Expression Matching
来源:互联网 发布:音频矩阵 编辑:程序博客网 时间:2024/06/06 07:49
反正我是想不出来
注意几个case的情况
public class Solution { public boolean isMatch(String s, String p) { // 反正我是想不出来 http://www.cnblogs.com/springfor/p/3893593.html if(p.length()==0) return s.length()==0; if(p.length()==1) return (s.length()==1 &&(p.charAt(0)==s.charAt(0)||p.charAt(0)=='.')); if(p.charAt(1)!='*'){ if(s.length()<1) return false; return (s.charAt(0)==p.charAt(0)||p.charAt(0)=='.')&&(isMatch(s.substring(1), p.substring(1))); }else{ while(s.length()>0&&(p.charAt(0)==s.charAt(0)||p.charAt(0)=='.')){ if(isMatch(s , p.substring(2))) return true; s = s.substring(1); // p= a*????; s = aaaaa???? } return isMatch(s, p.substring(2)); // p= b*?????, s = a???? } }}
同类型还有Wildcard Matching
0 0
- 天题之Regular Expression Matching
- leetcode之Regular Expression Matching
- LeetCode之Regular Expression Matching
- 【Leetcode】之Regular Expression Matching
- 每日算法之九:Regular Expression Matching
- LeetCode之10 --- Regular Expression Matching
- leetcode之路010 Regular Expression Matching
- leetcode10-Regular Expression Matching之Java版本
- Algorithm之路十:Regular Expression Matching
- leetcode 第10题 Regular Expression Matching
- 第46题 Regular Expression Matching
- Hard 10题 Regular Expression Matching
- leetcode 第10题 Regular Expression Matching
- LeetCode: Regular Expression Matching
- LeetCode: Regular Expression Matching
- leetcode Regular Expression Matching
- [Leetcode] Regular Expression Matching
- Regular Expression Matching
- C++ enum的使用
- Lock与synchronized
- Opengl学习笔记:(一).Ply文件文件格式和文件读取
- 黑马程序员-Java基础学习(函数)
- Java实现多项式
- 天题之Regular Expression Matching
- Fir平台上自动更新app的版本
- String类常用功能
- meanShift算法介绍
- 如何开发一个仿微信的 Web IM?
- 第17课时,自测
- opengGL深度测试介绍及代码测试
- This application failed to start because it could not find or load the Qt platform plugin "xcb".
- IIS上传文件大小限制