摘要:
这道题在Best Time to Buy and Sell Stock III做过,那道题只是把k取了2而已 递推式依然是 local[i][j]=max(global[i-1][j-1]+max(diff,0),local[i-1][j]+diff), global[i][j]=max(local 阅读全文
posted @ 2015-03-01 12:40
neverlandly
阅读(3460)
评论(0)
推荐(0)
摘要:
这道题要求in-place做法,不能使用extra space, 那么,做法跟Rotate Array那道题非常相似 (1)reverse the whole array (2)reverse each subarray seperated by ' ' 注意不要忘了reverse最后一个word 阅读全文
posted @ 2015-03-01 07:49
neverlandly
阅读(6591)
评论(0)
推荐(0)
摘要:
Naive 方法就是两层循环,外层for(int i=0; i<=s.length()-10; i++), 内层for(int j=i+1; j<=s.length()-10; j++), 比较两个字符串s.substring(i, i+10)和s.substring(j, j+10)是否equal 阅读全文
posted @ 2015-03-01 07:31
neverlandly
阅读(478)
评论(1)
推荐(0)
摘要:
Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:... 阅读全文
posted @ 2015-03-01 05:19
neverlandly
阅读(1722)
评论(0)
推荐(0)
浙公网安备 33010602011771号