08 2020 档案

摘要:JAVA: public final int findPoisonedDuration(int[] timeSeries, int duration) { if (timeSeries.length == 0 || duration == 0) { return 0; } int cur = 1; 阅读全文
posted @ 2020-08-27 22:04 牛有肉 阅读(193) 评论(0) 推荐(0) 编辑
摘要:JAVA 剪枝前: public final int findContentChildren(int[] g, int[] s) { if (s.length == 0 || g.length == 0) { return 0; } Arrays.sort(s); int re = 0; int s 阅读全文
posted @ 2020-08-26 00:11 牛有肉 阅读(222) 评论(0) 推荐(0) 编辑
摘要:JAVA: public final int maxNonOverlapping(int[] nums, int target) { int re = 0; int point = 0; while (point < nums.length) { int sum = 0; Set<Integer> 阅读全文
posted @ 2020-08-25 23:17 牛有肉 阅读(270) 评论(0) 推荐(0) 编辑
摘要:JAVA DFS 解法: public final int numIslands(char[][] grid) { int re = 0; for (int x = 0; x < grid.length; x++) { for (int y = 0; y < grid[0].length; y++) 阅读全文
posted @ 2020-08-22 01:20 牛有肉 阅读(324) 评论(0) 推荐(0) 编辑
摘要:回溯遍历去重题。 JAVA: List<List<Integer>> reList = new LinkedList<List<Integer>>(); public List<List<Integer>> findSubsequences(int[] nums) { search(nums, -1 阅读全文
posted @ 2020-08-20 00:58 牛有肉 阅读(350) 评论(0) 推荐(0) 编辑
摘要:JAVA: public final boolean isHappy(int n) { int next = next(n); while (n != 1 && n != next) { n = next(n); next = next(next(next)); } return n == 1; } 阅读全文
posted @ 2020-08-12 00:30 牛有肉 阅读(188) 评论(0) 推荐(0) 编辑
摘要:朴素解法,逻辑的渐进。 JAVA: public final int[][] merge(int[][] intervals) { sort(intervals); Stack<int[]> reStack = new Stack<int[]>(); for (int i = 0; i < inte 阅读全文
posted @ 2020-08-09 20:24 牛有肉 阅读(145) 评论(0) 推荐(0) 编辑
摘要:思路比较简单,可以采用计数法,不知为何会被分为中等。 JAVA: public final void sortColors(int[] nums) { int num0 = 0; int num1 = 0; int num2 = 0; for (int i = 0; i < nums.length; 阅读全文
posted @ 2020-08-09 00:46 牛有肉 阅读(222) 评论(0) 推荐(0) 编辑
摘要:思路很明显,折半查找。 JAVA: public final boolean searchMatrix(int[][] matrix, int target) { if (matrix.length == 0 || matrix[0].length == 0) { return false; } r 阅读全文
posted @ 2020-08-09 00:26 牛有肉 阅读(207) 评论(0) 推荐(0) 编辑
摘要:JAVA 哈希去重: final Set<String> reSet = new HashSet<String>(); public final String[] permutation(String S) { search(S, new HashSet<Integer>(), new String 阅读全文
posted @ 2020-08-07 20:32 牛有肉 阅读(420) 评论(0) 推荐(0) 编辑
摘要:JAVA: int an = 0; public final int countArrangement(int N) { search(N, new HashSet<Integer>(), 0); return an; } private final void search(int n, Set<I 阅读全文
posted @ 2020-08-06 23:51 牛有肉 阅读(81) 评论(0) 推荐(0) 编辑
摘要:JAVA 分治: public final int mincostTickets(int[] days, int[] costs) { return minCost(days, costs, days.length - 1, new int[days.length]); } private fina 阅读全文
posted @ 2020-08-06 23:50 牛有肉 阅读(205) 评论(0) 推荐(0) 编辑
摘要:JAVA : List<String> reList = new LinkedList<String>(); public List<String> generateParenthesis(int n) { search(0, n, n, new StringBuilder()); return r 阅读全文
posted @ 2020-08-05 22:09 牛有肉 阅读(131) 评论(0) 推荐(0) 编辑
摘要:Kadnae 解法: var kConcatenationMaxSum = function (arr, k) { let sum = arr[0]; let newK = k > 2 ? 2 : k; let pre = 0; let an = 0; for (let i = 0; i < new 阅读全文
posted @ 2020-08-04 00:00 牛有肉 阅读(196) 评论(0) 推荐(0) 编辑
摘要:暴力: final int mod = 1000000007; int an = 0; public final int kConcatenationMaxSum(int[] arr, int k) { int length = arr.length; int newLength = length 阅读全文
posted @ 2020-08-03 23:58 牛有肉 阅读(268) 评论(0) 推荐(0) 编辑
摘要:JAVA 回溯解法: public final String[] permutation(String s) { Set<String> reSet = new HashSet<String>(); search(s, 0, reSet, new StringBuilder(), new HashS 阅读全文
posted @ 2020-08-02 18:28 牛有肉 阅读(226) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示