substring with star
来源:互联网 发布:91苹果手机助手 mac版 编辑:程序博客网 时间:2024/05/26 22:56
实现boolean isSubstring(String s, String p). 如果p是s的substring,就返回true。 p可以是带有'*'的,一个'*'可以代表0或者多个任意字符
public static void main(String[] args) {System.out.println(isSubStr("abcde", "bcd"));System.out.println(isSubStr("abcde", "b*d"));System.out.println(isSubStr("abcde", "b*f"));System.out.println(isSubStr("abcde", "b*"));}static boolean isSubStr(String s, String p){ String strInP; int i =0; for(; i<p.length(); i++){ if(p.charAt(i)=='*') break; } strInP = p.substring(0, i); int foundIndex = s.indexOf(strInP); if(foundIndex==-1) return false; return i>=p.length()||isSubStr(s.substring(foundIndex+strInP.length()), p.substring(i+1)); }
0 0
- substring with star
- Star With ...Connect By
- Star
- Star
- Star
- star
- star
- Longest Substring With Repeating Characters
- Web Scraping with Python: 使用 Python 爬 GitHub Star 数
- [Leetcode]Substring with Concatenation of All Words & Minimum Window Substring
- The Longest Common Substring with Maximal Consecutive
- SubString match with a big file
- LeetCode: Substring with Concatenation of All Words
- LeetCode : Substring with Concatenation of All Words
- LeetCode29: Substring with Concatenation of All Words
- [Leetcode] Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- C++在单继承、多继承、虚继承时,构造函数、复制构造函数、赋值操作符、析构函数的执行顺序和执行内容
- CODEFORCES 438D The Child and Sequence <二叉树>
- 使用POSIX Threads进行多线程编程(二) ——使用互斥量同步线程
- 判断二叉树是不是平衡
- Unity传统动画的实现
- substring with star
- hdu 5791 2016多校5
- 编写通用的java代码执行任意adb命令
- onmousedown事件---&&浏览器检测---&&脚本隐藏
- 逐步回归(step regression)和分段回归(stagewise regression)
- NLog简易入门
- [Go语言]我的第十一个Go语言程序
- WIN-32 API
- 线程信号量