摘要:
https://leetcode.com/problems/evaluate-division/discuss/88169/Java-AC-Solution-using-graph 建立graph dfsvalue是按照值建立的 这样dfs的时候可以直接乘 阅读全文
摘要:
https://leetcode.com/problems/find-peak-element/discuss/50232/Find-the-maximum-by-binary-search-(recursion-and-iteration) 阅读全文
摘要:
1 class Solution { 2 public List topKFrequent(String[] words, int k) { 3 HashMap map = new HashMap(); 4 List res = new ArrayList(); 5 if(words.length == 0) return res... 阅读全文
摘要:
1 class Trie { 2 class TrieNode{ 3 char label; 4 boolean flag; 5 TrieNode[] children; 6 TrieNode(char c){ 7 label = c; 8 flag = fal... 阅读全文
摘要:
1 class Solution { 2 Random random = new Random(); 3 int[] arr; 4 5 public Solution(int[] nums) { 6 arr = nums; 7 } 8 9 public int pick(int target) { 10 ... 阅读全文
摘要:
这道题要用Set去做因为没有sort过 所以在后面也可能出现重复的东西 https://leetcode.com/problems/increasing-subsequences/discuss/97130/Java-20-lines-backtracking-solution-using-set- 阅读全文
摘要:
1 class Solution { 2 public double knightProbability(int N, int K, int r, int c) { 3 if(K == 0) return 1; 4 double[][][] dp = new double[K+1][N][N]; 5 int[][] move = ... 阅读全文
摘要:
每个位置都是边界 二分法找 阅读全文
摘要:
1 class Solution { 2 public int findLengthOfLCIS(int[] nums) { 3 if(nums.length == 0) return 0; 4 if(nums.length == 1) return 1; 5 int[] dp = new int[nums.length]; 6... 阅读全文