摘要:
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".StringBuilder + reverse methodpublic class Solution { public String addBinary(String a, String b) { if(a == null || a.equals("")) return b; if(b == null || b 阅读全文
摘要:
Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.思路:建Hashtable,用排序过的string作为key,它的anagram作为ArrayList题目的意思是给一个String数组,找出其中由相同字母组成的单词。例如:S = ["abc", "bca", "bac", "bbb", "bbca", "abc 阅读全文
摘要:
Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) Insert a characterb) Delete a characterc) Replace a character正确的解出来方法是用二维的dp。假如我们要将字符串str1变成str2,sstr1(i)是s 阅读全文
摘要:
http://blog.csdn.net/twtsa/article/details/8120269http://blog.csdn.net/sunjilong/article/details/8254108public class Solution { public int maximalRectangle(char[][] matrix) { if(matrix.length=0;j--){ // 如果遍历元素为'1',right[j]取R和right[j]中的最小值 if(matrix[i][j]=='1')... 阅读全文