上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 22 下一页
摘要: 1 class Solution { 2 public int maxProfit(int[] prices) { 3 int len = prices.length; 4 if(len == 0 || len == 1) return 0; 5 int res = 0; 6 int buy = prices[0... 阅读全文
posted @ 2018-09-23 00:09 jasoncool1 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 从下面往上 可以建立一个cache 这个点往下search过已经知道最小值了 下一次访问的时候就可以直接取值, 因为一般一个点都会被上面访问两次,如果不这样就会time limit错误 阅读全文
posted @ 2018-09-22 23:37 jasoncool1 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 List res = new ArrayList(); 3 public List getRow(int rowIndex) { 4 helper(1, rowIndex + 1, new ArrayList(), null); 5 return res; 6 7 }... 阅读全文
posted @ 2018-09-22 04:29 jasoncool1 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 List> res = new ArrayList(); 3 public List> generate(int numRows) { 4 helper(1, numRows, new ArrayList(), null); 5 return res; 6 7 }... 阅读全文
posted @ 2018-09-22 00:25 jasoncool1 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public void connect(TreeLinkNode root) { 3 if(root == null) return; 4 Queue queue = new LinkedList(); 5 queue.offer(root); 6 int size = ... 阅读全文
posted @ 2018-09-21 23:49 jasoncool1 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public void connect(TreeLinkNode root) { 3 if(root == null) return; 4 Queue queue = new LinkedList(); 5 queue.offer(root); 6 int size = ... 阅读全文
posted @ 2018-09-21 23:44 jasoncool1 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 把左边=null, 把最左边遍历到null 保证已经flatten 然后再弄右边 然后把root.right跟左边连接,再把右边连接到root.right的最下面 https://leetcode.com/problems/flatten-binary-tree-to-linked-list/dis 阅读全文
posted @ 2018-09-21 23:03 jasoncool1 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 List> res = new ArrayList(); 3 public List> pathSum(TreeNode root, int sum) { 4 if(root == null) return res; 5 backtrack(root, sum, new ArrayList());... 阅读全文
posted @ 2018-09-21 09:11 jasoncool1 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 只有在两个子节点都是null的叶节点才有可能符合条件\ 阅读全文
posted @ 2018-09-21 08:46 jasoncool1 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 注意只有一个子节点的情况,分开讨论 阅读全文
posted @ 2018-09-21 08:02 jasoncool1 阅读(108) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 22 下一页