摘要: https://leetcode.com/problems/evaluate-division/discuss/88169/Java-AC-Solution-using-graph 建立graph dfsvalue是按照值建立的 这样dfs的时候可以直接乘 阅读全文
posted @ 2018-10-28 12:27 jasoncool1 阅读(177) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/find-peak-element/discuss/50232/Find-the-maximum-by-binary-search-(recursion-and-iteration) 阅读全文
posted @ 2018-10-28 11:06 jasoncool1 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2018-10-28 10:27 jasoncool1 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2018-10-28 06:19 jasoncool1 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 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 ... 阅读全文
posted @ 2018-10-28 05:36 jasoncool1 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 这道题要用Set去做因为没有sort过 所以在后面也可能出现重复的东西 https://leetcode.com/problems/increasing-subsequences/discuss/97130/Java-20-lines-backtracking-solution-using-set- 阅读全文
posted @ 2018-10-28 04:27 jasoncool1 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 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 = ... 阅读全文
posted @ 2018-10-28 01:54 jasoncool1 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 每个位置都是边界 二分法找 阅读全文
posted @ 2018-10-28 01:03 jasoncool1 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2018-10-28 00:17 jasoncool1 阅读(101) 评论(0) 推荐(0) 编辑