https://oj.leetcode.com/problems/simplify-path/http://blog.csdn.net/linhuanmars/article/details/23972563publicclassSolution{
publicStringsimplifyPath(Stringpath){
if(path==null)
returnnull;
String[]paths=path.split("/");
Stack<String>stack=newStack&..
分类:
其他好文 时间:
2015-01-04 19:43:47
阅读次数:
182
https://oj.leetcode.com/problems/edit-distance/http://blog.csdn.net/linhuanmars/article/details/24213795publicclassSolution{
publicintminDistance(Stringword1,Stringword2)
{
if(word1==null||word2==null)
return-1;
if(word1.isEmpty())
returnword2.length();//I..
分类:
其他好文 时间:
2015-01-04 19:40:46
阅读次数:
148
https://oj.leetcode.com/problems/set-matrix-zeroes/http://blog.csdn.net/linhuanmars/article/details/24066199publicclassSolution{
publicvoidsetZeroes(int[][]matrix)
{
//SolutionA:
//setZeroes_NoExtraSpace(matrix);
//SolutionB:
setZeroes_ExtraRowAndCol(matri..
分类:
其他好文 时间:
2015-01-04 19:40:25
阅读次数:
194
https://oj.leetcode.com/problems/sort-colors/http://blog.csdn.net/linhuanmars/article/details/24286349publicclassSolution{
publicvoidsortColors(int[]A)
{
//SolutionA:
sortColors_CountColor(A);
//SolutionB:
//sortColors_MergeSort(A,0,A.length-1);
}
///////..
分类:
其他好文 时间:
2015-01-04 19:37:46
阅读次数:
167
https://oj.leetcode.com/problems/search-a-2d-matrix/http://blog.csdn.net/linhuanmars/article/details/24216235publicclassSolution{
publicbooleansearchMatrix(int[][]matrix,inttarget){
//Searchfromrightcorner
intn=matrix.length;//howmanyrows.
intm=matrix[0].le..
分类:
其他好文 时间:
2015-01-04 19:37:46
阅读次数:
131
https://oj.leetcode.com/problems/subsets/http://blog.csdn.net/linhuanmars/article/details/24286377publicclassSolution{
publicList<List<Integer>>subsets(int[]S){
Arrays.sort(S);
List<List<Integer>>results=newArrayList<>();
hel..
分类:
其他好文 时间:
2015-01-04 19:35:38
阅读次数:
146
https://oj.leetcode.com/problems/combinations/http://blog.csdn.net/linhuanmars/article/details/21260217publicclassSolution{
publicList<List<Integer>>combine(intn,intk)
{
List<List<Integer>>results=newArrayList<>();
help(n,k,0,n..
分类:
其他好文 时间:
2015-01-04 19:34:42
阅读次数:
125
https://oj.leetcode.com/problems/subsets/http://blog.csdn.net/linhuanmars/article/details/24286377publicclassSolution{
publicList<List<Integer>>subsets(int[]S){
Arrays.sort(S);
List<List<Integer>>results=newArrayList<>();
hel..
分类:
其他好文 时间:
2015-01-04 19:34:20
阅读次数:
306
https://oj.leetcode.com/problems/word-search/http://blog.csdn.net/linhuanmars/article/details/24336987publicclassSolution{
publicbooleanexist(char[][]board,Stringword)
{
Map<Character,List<P>>map=buildMap(board);
booleanr=visit(map,word.toCharAr..
分类:
其他好文 时间:
2015-01-04 19:33:20
阅读次数:
146
https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/http://blog.csdn.net/linhuanmars/article/details/24343525publicclassSolution{
publicintremoveDuplicates(int[]A){
if(A==null)
return-1;//invalidinput
if(A.length==0||A.length==1)
retur..
分类:
其他好文 时间:
2015-01-04 19:32:41
阅读次数:
133