摘要:
回溯遍历去重题。 JAVA: List<List<Integer>> reList = new LinkedList<List<Integer>>(); public List<List<Integer>> findSubsequences(int[] nums) { search(nums, -1 阅读全文
摘要:
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; } 阅读全文
摘要:
朴素解法,逻辑的渐进。 JAVA: public final int[][] merge(int[][] intervals) { sort(intervals); Stack<int[]> reStack = new Stack<int[]>(); for (int i = 0; i < inte 阅读全文
摘要:
思路比较简单,可以采用计数法,不知为何会被分为中等。 JAVA: public final void sortColors(int[] nums) { int num0 = 0; int num1 = 0; int num2 = 0; for (int i = 0; i < nums.length; 阅读全文
摘要:
思路很明显,折半查找。 JAVA: public final boolean searchMatrix(int[][] matrix, int target) { if (matrix.length == 0 || matrix[0].length == 0) { return false; } r 阅读全文
摘要:
JAVA 哈希去重: final Set<String> reSet = new HashSet<String>(); public final String[] permutation(String S) { search(S, new HashSet<Integer>(), new String 阅读全文
摘要:
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 阅读全文
摘要:
JAVA 分治: public final int mincostTickets(int[] days, int[] costs) { return minCost(days, costs, days.length - 1, new int[days.length]); } private fina 阅读全文
摘要:
JAVA : List<String> reList = new LinkedList<String>(); public List<String> generateParenthesis(int n) { search(0, n, n, new StringBuilder()); return r 阅读全文
摘要:
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 阅读全文