![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
String
baidu_17223201
这个作者很懒,什么都没留下…
展开
-
Add Binary
public class Solution { public String addBinary(String a, String b) { StringBuffer sum = new StringBuffer(); int carry = 0; for(int i = a.length() - 1, j = b.length() - 1;原创 2014-07-08 02:37:16 · 265 阅读 · 0 评论 -
Implement strStr()
public class Solution { public String strStr(String haystack, String needle) { if(needle == "") { return haystack; } for(int i = 0; i <= haystack.length() - nee原创 2014-07-08 02:02:25 · 187 阅读 · 0 评论 -
Wildcard Matching
public class Solution { public boolean isMatch(String s, String p) { int i = 0, j = 0; // p.charAt(j) == '*', sAsterisk = i, pAsterisk = ++j int sAsterisk = 0, pAsterisk =原创 2014-07-08 06:13:19 · 254 阅读 · 0 评论 -
Valid Palindrome
public class Solution { public boolean isPalindrome(String s) { s = s.trim().replaceAll("\\W", "").toLowerCase(); for(int i = 0; i < (s.length() + 1) / 2; i++) { if(s.c原创 2014-07-08 01:55:02 · 198 阅读 · 0 评论 -
String to Integer (atoi)
public class Solution { public int atoi(String str) { str = str.trim(); if(str.matches("(\\+?|-?)\\d+.*")) { boolean isPos = true; if(str.charAt(0) == '-')原创 2014-07-08 02:12:59 · 205 阅读 · 0 评论 -
Longest Palindromic Substring
public class Solution { public String longestPalindrome(String s) { if(s.length() < 2) { return s; } // DP // P[i][j] == true // s.substring(i,原创 2014-07-08 02:43:11 · 229 阅读 · 0 评论 -
Regular Expression Matching
public class Solution { public boolean isMatch(String s, String p) { if(p.length() == 0) { return s.length() == 0; } if(p.length() == 1) { return s.原创 2014-07-08 05:28:01 · 223 阅读 · 0 评论