diff --git a/data/progress.txt b/data/progress.txt index 2d4e4c64..1de65b0d 100644 --- a/data/progress.txt +++ b/data/progress.txt @@ -1,6 +1,7 @@ +20240229: 39 20240228: 20,21,23,33(again) 20240227: 1,3,5,4,19 -20231218: 57(todo),58(todo),268,61(todo),297 +20231218: 57(todo),58(todo),268,61(stodo),297 20231211: 39,53,48,56 20231208: 33 20231206: 19,003 diff --git a/data/to_review.txt b/data/to_review.txt index c20ed727..0579ba1e 100644 --- a/data/to_review.txt +++ b/data/to_review.txt @@ -1,41 +1,47 @@ +2024-04-24 -> ['39'] 2024-04-23 -> ['20,21,23,33(again)'] 2024-04-22 -> ['1,3,5,4,19'] +2024-04-03 -> ['39'] 2024-04-02 -> ['20,21,23,33(again)'] 2024-04-01 -> ['1,3,5,4,19'] +2024-03-21 -> ['39'] 2024-03-20 -> ['20,21,23,33(again)'] 2024-03-19 -> ['1,3,5,4,19'] +2024-03-13 -> ['39'] 2024-03-12 -> ['20,21,23,33(again)'] 2024-03-11 -> ['1,3,5,4,19'] +2024-03-08 -> ['39'] 2024-03-07 -> ['20,21,23,33(again)'] 2024-03-06 -> ['1,3,5,4,19'] +2024-03-05 -> ['39'] 2024-03-04 -> ['20,21,23,33(again)'] -2024-03-03 -> ['1,3,5,4,19'] -2024-03-02 -> ['20,21,23,33(again)'] -2024-03-01 -> ['20,21,23,33(again)', '1,3,5,4,19'] +2024-03-03 -> ['39', '1,3,5,4,19'] +2024-03-02 -> ['39', '20,21,23,33(again)'] +2024-03-01 -> ['39', '20,21,23,33(again)', '1,3,5,4,19'] 2024-02-29 -> ['20,21,23,33(again)', '1,3,5,4,19'] 2024-02-28 -> ['1,3,5,4,19'] -2024-02-11 -> ['57(todo),58(todo),268,61(todo),297'] +2024-02-11 -> ['57(todo),58(todo),268,61(stodo),297'] 2024-02-04 -> ['39,53,48,56'] 2024-01-30 -> ['19,003'] 2024-01-29 -> ['23'] 2024-01-28 -> ['55,45'] -2024-01-21 -> ['57(todo),58(todo),268,61(todo),297'] +2024-01-21 -> ['57(todo),58(todo),268,61(stodo),297'] 2024-01-14 -> ['39,53,48,56'] 2024-01-09 -> ['19,003'] -2024-01-08 -> ['57(todo),58(todo),268,61(todo),297', '23'] +2024-01-08 -> ['57(todo),58(todo),268,61(stodo),297', '23'] 2024-01-07 -> ['55,45'] 2024-01-02 -> ['452,406,135'] 2024-01-01 -> ['39,53,48,56'] -2023-12-31 -> ['57(todo),58(todo),268,61(todo),297', '134'] +2023-12-31 -> ['57(todo),58(todo),268,61(stodo),297', '134'] 2023-12-28 -> ['53'] 2023-12-27 -> ['19,003'] -2023-12-26 -> ['57(todo),58(todo),268,61(todo),297', '23'] +2023-12-26 -> ['57(todo),58(todo),268,61(stodo),297', '23'] 2023-12-25 -> ['55,45'] 2023-12-24 -> ['39,53,48,56'] -2023-12-23 -> ['57(todo),58(todo),268,61(todo),297'] -2023-12-21 -> ['57(todo),58(todo),268,61(todo),297'] -2023-12-20 -> ['57(todo),58(todo),268,61(todo),297'] -2023-12-19 -> ['57(todo),58(todo),268,61(todo),297', '39,53,48,56', '19,003'] +2023-12-23 -> ['57(todo),58(todo),268,61(stodo),297'] +2023-12-21 -> ['57(todo),58(todo),268,61(stodo),297'] +2023-12-20 -> ['57(todo),58(todo),268,61(stodo),297'] +2023-12-19 -> ['57(todo),58(todo),268,61(stodo),297', '39,53,48,56', '19,003'] 2023-12-18 -> ['23'] 2023-12-17 -> ['55,45'] 2023-12-16 -> ['39,53,48,56'] diff --git a/doc/cheatsheet/backtrack.md b/doc/cheatsheet/backtrack.md index 1d0e6f5f..e2592547 100644 --- a/doc/cheatsheet/backtrack.md +++ b/doc/cheatsheet/backtrack.md @@ -299,7 +299,12 @@ else{ for(int i = start; i < nums.length; i++){ tempList.add(nums[i]); - backtrack(list, tempList, nums, remain - nums[i], i); // not i + 1 because we can reuse same elements + /** NOTE !!! + * + * use i, since we need to use start from current (i) index in recursion call + * (reuse current index) + */ + backtrack(list, tempList, nums, remain - nums[i], i); tempList.remove(tempList.size() - 1); } } diff --git a/leetcode_java/src/main/java/LeetCodeJava/BackTrack/CombinationSum.java b/leetcode_java/src/main/java/LeetCodeJava/BackTrack/CombinationSum.java index ebaf5aa5..0b0f8b90 100644 --- a/leetcode_java/src/main/java/LeetCodeJava/BackTrack/CombinationSum.java +++ b/leetcode_java/src/main/java/LeetCodeJava/BackTrack/CombinationSum.java @@ -18,6 +18,7 @@ public List> combinationSum(int[] candidates, int target) { return null; } + // NOTE !!! we sore here Arrays.sort(candidates); List> res = new ArrayList<>(); @@ -46,7 +47,11 @@ private void backTrack(int[] candidates, int target, List tmp, List