上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 17 下一页
摘要: The problem of this solution can be BFS and DFS. BFS is easy to understand. The following is DFS solution: private List<Integer> res = new ArrayList<> 阅读全文
posted @ 2022-02-09 07:57 阳光明媚的菲越 阅读(17) 评论(0) 推荐(0) 编辑
摘要: The first solution, the easiest one, time complexity: O(nlog(n)) public int findKthLargest(int[] nums, int k) { Arrays.sort(nums); if(k<=nums.length) 阅读全文
posted @ 2022-02-09 07:39 阳光明媚的菲越 阅读(17) 评论(0) 推荐(0) 编辑
摘要: For this problem, we must know the sign just before the num. For example, s = "3+2*2", when we deal with the first 2, we must know '+' is just before 阅读全文
posted @ 2022-02-09 02:27 阳光明媚的菲越 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 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) 推荐(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 阳光明媚的菲越 阅读(17) 评论(0) 推荐(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 阳光明媚的菲越 阅读(17) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2022-02-08 13:29 阳光明媚的菲越 阅读(0) 评论(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 阳光明媚的菲越 阅读(29) 评论(0) 推荐(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 阳光明媚的菲越 阅读(18) 评论(0) 推荐(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) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 17 下一页