摘要:
Just treat the Nested List as a tree, and dfs it: private int sum =0; public int depthSum(List<NestedInteger> nestedList) { helper(nestedList, 1); ret
阅读全文
posted @ 2022-02-08 14:37
阳光明媚的菲越
阅读(16)
推荐(0)
编辑
摘要:
The simplest way that I can think to solve this problem is using a PriorityQueue: public int[][] kClosest(int[][] points, int k) { PriorityQueue<int[]
阅读全文
posted @ 2022-02-08 14:10
阳光明媚的菲越
阅读(19)
推荐(0)
编辑
摘要:
For example, if the int[] w ={3,14,1,7}, we can make a presum array based on it: int[] presums = {3, 17, 18, 25} We using Ramdom's nextInt() to genera
阅读全文
posted @ 2022-02-08 13:46
阳光明媚的菲越
阅读(18)
推荐(0)
编辑
posted @ 2022-02-08 13:29
阳光明媚的菲越
阅读(0)
推荐(0)
编辑
摘要:
This problem can be solved by using the solution of 236. Lowest Common Ancestor of a Binary Tree. While the tree here is a binary search tree, so the
阅读全文
posted @ 2022-02-08 09:44
阳光明媚的菲越
阅读(31)
推荐(0)
编辑
摘要:
This problem is just as same as "235. Lowest Common Ancestor of a Binary Search Tree", the only difference is, 235 is two points, 1676 is 1~n points.
阅读全文
posted @ 2022-02-08 08:55
阳光明媚的菲越
阅读(20)
推荐(0)
编辑
摘要:
The first solution of this problem can be based on the 236. Lowest Common Ancestor of a Binary Tree too: public Node lowestCommonAncestor(Node p, Node
阅读全文
posted @ 2022-02-08 08:40
阳光明媚的菲越
阅读(33)
推荐(0)
编辑