10 Regular Expression Matching
来源:互联网 发布:java软件开发工具 编辑:程序博客网 时间:2024/05/22 04:26
public class No10 { public static void main(String[] args) { System.out.println(isMatch("aa", "a")); System.out.println(isMatch("aa", "aa")); System.out.println(isMatch("aaa", "aa")); System.out.println(isMatch("aa", "a*")); System.out.println(isMatch("aa", ".*")); System.out.println(isMatch("ab", ".*")); System.out.println(isMatch("aab", "c*a*b")); } public static boolean isMatch(String s, String p) { if (p.length() == 0) return s.length() == 0; else if (s.length() == 0) { if (p.length() > 1 && p.charAt(1) == '*') return isMatch(s, p.substring(2)); else return false; } else if (p.length() > 1 && p.charAt(1) == '*') { if (isMatch(s, p.substring(2))) return true; else if (s.charAt(0) == p.charAt(0) || p.charAt(0) == '.') return isMatch(s.substring(1), p); else return false; } else return (s.charAt(0) == p.charAt(0) || p.charAt(0) == '.') && isMatch(s.substring(1), p.substring(1)); }}
0 0
- 10、Regular Expression Matching
- 10,Regular Expression Matching
- 10Regular Expression Matching
- 10 Regular Expression Matching
- 10、Regular Expression Matching
- 10Regular Expression Matching
- 【10】Regular Expression Matching
- 10-Regular Expression Matching
- Leetcode【10】:Regular Expression Matching
- [leetcode 10] Regular Expression Matching
- LeetCode(10) Regular Expression Matching
- [leetcode 10] Regular Expression Matching
- leetcode.10------------Regular Expression Matching
- [leetcode] 10 Regular Expression Matching
- [leetcode] 10 Regular Expression Matching
- LeetCode 10:《Regular Expression Matching》
- leecode 10 Regular Expression Matching
- leetcode 10: Regular Expression Matching
- coreseek 异常退出 FATAL: INTERNAL ERROR: unknown matching mode (mode=5)
- 一、cocoapods的使用
- 12 Integer to Roman
- debian网关不同子网的设定
- poj 3069 Saruman's Army 【贪心】
- 10 Regular Expression Matching
- 华为oj_放苹果
- new和malloc的区别
- [零基础学python]让人欢喜让人忧的迭代
- 11 Container With Most Water
- ADO数据库编程
- code==200是什么意思
- 多线程
- Docker学习总结之Run命令介绍