摘要:
160. Intersection of Two Linked Lists 分别从AB循环两次。如果第一次没循环到,第二次就会在节点相遇。 public class Solution { public ListNode getIntersectionNode(ListNode headA, List 阅读全文
摘要:
120. Triangle 从倒数第二行找,然后逐个遍历这个DP数组,对于每个数字,和它之后的元素比较选择较小的再加上面一行相邻位置的元素做为新的元素,然后一层一层的向上扫描 class Solution { public int minimumTotal(List<List<Integer>> t 阅读全文
摘要:
216. Combination Sum III 保证subset.size( ) == k && target == 0的时候结束DFS subset.size( ) > k || target < 0返回。 class Solution { public List<List<Integer>> 阅读全文
摘要:
39. Combination Sum Combination,组合问题用DFS罗列全部的答案。 class Solution { public List<List<Integer>> combinationSum(int[] candidates, int target) { List<List< 阅读全文
摘要:
113. Path Sum II 利用DFS的三要素, 出口1,出口2,拆解,记得回溯的时候要回退一位path。 class Solution { public List<List<Integer>> pathSum(TreeNode root, int sum) { List<List<Integ 阅读全文
摘要:
49. Group Anagrams class Solution { public List<List<String>> groupAnagrams(String[] strs) { HashMap<String, List<String>> map = new HashMap<>(); if(s 阅读全文