摘要:
Dynamic Programming 阅读全文
摘要:
1 public class Solution { 2 public int[] twoSum(int[] numbers, int target) { 3 int left = 0; 4 int right = numbers.length - 1; 5 while (left < right) { 6 ... 阅读全文
摘要:
这题一开始以为是求平均数,后来发现是求中位数,如果是偶数大小随便取中间两个中任何一个都可以 阅读全文
摘要:
1 /** 2 * Definition for a binary tree node. 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * TreeNode(int x) { val = x; } 8 * } 9 ... 阅读全文
摘要:
ASCII就只有256位,用一个array就可以了 阅读全文
摘要:
这题的关键点在于对数组的重排序方法,高度先由高到低排列不会影响第二个参数,因为list.add的方法在指定index后面插入,因此对于同高的人来说需要对第二个参数由低到高排,具体代码如下 int[][] ans = (int[][])pList.toArray();会报错,只能遍历赋值了 阅读全文