diff --git a/data/progress.txt b/data/progress.txt index ec247c4e..2d4e4c64 100644 --- a/data/progress.txt +++ b/data/progress.txt @@ -1,4 +1,4 @@ -20240228: 20,21 +20240228: 20,21,23,33(again) 20240227: 1,3,5,4,19 20231218: 57(todo),58(todo),268,61(todo),297 20231211: 39,53,48,56 diff --git a/data/to_review.txt b/data/to_review.txt index 6c865961..c20ed727 100644 --- a/data/to_review.txt +++ b/data/to_review.txt @@ -1,18 +1,18 @@ -2024-04-23 -> ['20,21'] +2024-04-23 -> ['20,21,23,33(again)'] 2024-04-22 -> ['1,3,5,4,19'] -2024-04-02 -> ['20,21'] +2024-04-02 -> ['20,21,23,33(again)'] 2024-04-01 -> ['1,3,5,4,19'] -2024-03-20 -> ['20,21'] +2024-03-20 -> ['20,21,23,33(again)'] 2024-03-19 -> ['1,3,5,4,19'] -2024-03-12 -> ['20,21'] +2024-03-12 -> ['20,21,23,33(again)'] 2024-03-11 -> ['1,3,5,4,19'] -2024-03-07 -> ['20,21'] +2024-03-07 -> ['20,21,23,33(again)'] 2024-03-06 -> ['1,3,5,4,19'] -2024-03-04 -> ['20,21'] +2024-03-04 -> ['20,21,23,33(again)'] 2024-03-03 -> ['1,3,5,4,19'] -2024-03-02 -> ['20,21'] -2024-03-01 -> ['20,21', '1,3,5,4,19'] -2024-02-29 -> ['20,21', '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-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-04 -> ['39,53,48,56'] diff --git a/doc/cheatsheet/binary_search.md b/doc/cheatsheet/binary_search.md index 851784f3..07866edd 100644 --- a/doc/cheatsheet/binary_search.md +++ b/doc/cheatsheet/binary_search.md @@ -49,6 +49,8 @@ - Garena/test1.py - Search in Rotated Sorted Array - LC 033 + - // CASE 1) sub array left is sorted + - // CASE 2) sub array right is sorted - Search in 2D array - LC 74 - Find min in Rotation array diff --git a/leetcode_java/src/main/java/LeetCodeJava/BinarySearch/SearchInRotatedSortedArray.java b/leetcode_java/src/main/java/LeetCodeJava/BinarySearch/SearchInRotatedSortedArray.java index 06eba827..b3cdc8c3 100644 --- a/leetcode_java/src/main/java/LeetCodeJava/BinarySearch/SearchInRotatedSortedArray.java +++ b/leetcode_java/src/main/java/LeetCodeJava/BinarySearch/SearchInRotatedSortedArray.java @@ -4,6 +4,10 @@ public class SearchInRotatedSortedArray { + // V0 + // IDEA : BINARY SEARCH + // CASE 1) sub array left is sorted + // CASE 2) sub array right is sorted public int search(int[] nums, int target) { if (nums.length == 0 || nums.equals(null)){ @@ -46,7 +50,7 @@ public int search(int[] nums, int target) { * - target > nums[r] || target < nums[mid] * */ - // Case 2: subarray on mid's left is sorted + // Case 1: subarray on mid's left is sorted /** NOTE !!! we compare mid with left, instead of 0 idx element */ else if (nums[mid] >= nums[l]) { if (target >= nums[l] && target < nums[mid]) { @@ -56,7 +60,7 @@ else if (nums[mid] >= nums[l]) { } } - // Case 3: subarray on mid's right is sorted + // Case 2: subarray on mid's right is sorted else { if (target <= nums[r] && target > nums[mid]) { l = mid + 1;