- 博客(5)
- 收藏
- 关注
翻译 [Leetcode] Best Time to Buy and Sell Stock III
public int maxProfit(int[] prices) { /* global[i][j]: i days, j transactions local[i][j]: i days, j transactions, the last is complete at the last day
2015-03-01 11:20:53 220
原创 [Leetcode] LRU Cache
public class LRUCache { class Node { int key; int value; Node left; Node right; Node(int k, int v){ this.key=k; this.value=v;
2015-02-18 11:26:32 237
原创 [Leetcode] Generate Parentheses
public ArrayList generateParenthesis(int n) { ArrayList res=new ArrayList(); StringBuilder sb=new StringBuilder(); helper(res,sb,n,n); return res; } public
2015-02-17 10:54:32 188
原创 [ LeetCode] Remove Duplicates from Sorted Array
两种办法,一种思考上比较细节,一种思考上比较简洁 public int removeDuplicates(int[] A) { if(A.length==0) return 0; if(A.length==1) return 1; int i=0; int j=0; while(i<A.length
2015-02-17 07:14:06 204
原创 [Leetcode] Median of Two Sorted Arrays
Problem: There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). My code: public class So
2015-01-21 11:19:11 234
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人