摘要:
509. 斐波那契数 class Solution { public int fib(int n) { if (n <= 1) return n; int dp[] = new int[n+1]; dp[0] = 0; dp[1] = 1; for (int i = 2; i <= n; i++) 阅读全文
摘要:
435. 无重叠区间 class Solution { public int eraseOverlapIntervals(int[][] intervals) { //转化为找无重叠区间个数的问题 //按右边界排序 Arrays.sort(intervals, (o1, o2) -> { if (o 阅读全文
摘要:
135. 分发糖果 class Solution { public int candy(int[] ratings) { int len = ratings.length; if (len == 0) return 0; //分配数组 int[] alot = new int[len]; //先从前 阅读全文
摘要:
1005. K 次取反后最大化的数组和 class Solution { public int largestSumAfterKNegations(int[] nums, int k) { Arrays.sort(nums); int res = 0; //反转负数 计算总和 int i = 0, 阅读全文
摘要:
53. 最大子数组和 class Solution { public int maxSubArray(int[] nums) { int count = 0, res = Integer.MIN_VALUE; int len = nums.length; for (int i = 0; i < le 阅读全文
摘要:
51. N 皇后 class Solution { private List<List<String>> res; //存第i行放置位置 private int[] place; public List<List<String>> solveNQueens(int n) { res = new Ar 阅读全文