Submit Binary-Search-1 PR - #2519
Conversation
Implement binary search in a sorted array of unknown size.
Implement binary search for rotated sorted array.
Implement binary search to find target in 2D matrix.
Search in Rotated Sorted Array (Exercise_1.py)You have submitted a solution for "Search a 2D Matrix" (LeetCode 74) instead of "Search in Rotated Sorted Array" (LeetCode 33). These are two different problems:
To solve the actual problem, you need to:
Here's a hint for the correct approach:
Please resubmit with the correct solution for "Search in Rotated Sorted Array". VERDICT: NEEDS_IMPROVEMENT Search in a Sorted Array of Unknown Size (Exercise_2.py)EEVOLUTION: [PASS or NEEDS_IMPROulMENT] VERDICT: NEEDS_IMPROVEMENT Search a 2D Matrix (Exercise_3.py)It looks like you've submitted a solution for a different problem ("Search in a Sorted Array of Unknown Size") instead of the required problem ("Search a 2D Matrix"). For the actual problem, you need to:
Here's a sketch of what the solution should look like: class Solution:
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
m, n = len(matrix), len(matrix[0])
low, high = 0, m * n - 1
while low <= high:
mid = low + (high - low) // 2
r, c = mid // n, mid % n
val = matrix[r][c]
if val == target:
return True
elif val > target:
high = mid - 1
else:
low = mid + 1
return FalsePlease resubmit with the correct solution for "Search a 2D Matrix." VERDICT: NEEDS_IMPROVEMENT |
No description provided.