Solved Problem 1 - Seach a 2d Matrix, Problem 2 - Search in a rotated sorted array and Problem 3 - Search in infinite sorted array#2492
Conversation
… sorted array and Problem 3 - Search in infinite sorted array
Search inside a Rotated Sorted Array (Problem1.cs)It seems there might be a misunderstanding. The problem you solved is "Search a 2D Matrix", but the problem you were asked to solve is "Search inside a Rotated Sorted Array". These are two distinct problems. For the rotated sorted array problem, you need to implement a binary search that accounts for the rotation. The key idea is to determine which half of the array is sorted and then check if the target lies within that sorted half. If it does, you continue the search in that half; otherwise, you search the other half. Here are the steps you should follow for the correct problem:
Your current solution does not address this logic. Please revisit the problem statement and implement the correct algorithm for the rotated sorted array. VERDICT: NEEDS_IMPROVEMENT Search Inside a Sorted Array whose Length is unknown (Problem2.cs)Your solution is well-written for the problem of searching in a rotated sorted array. However, it does not solve the problem presented here. The current problem requires handling an array of unknown size using the ArrayReader interface, which your code does not utilize. Instead, your code assumes a known array length and checks for rotation, which is not part of this problem. To correct this, you need to:
For example, you can start with low=0 and high=1, and while Please adjust your solution to address the correct problem. Your current approach is correct for a rotated sorted array, but not for this problem. VERDICT: NEEDS_IMPROVEMENT Search a 2D Matrix (Problem3.cs)It seems there might be a mix-up in the problems. Your solution is for "Search in a Sorted Array of Unknown Size", but the problem you were asked to solve is "Search a 2D Matrix". For the "Search a 2D Matrix" problem, you need to implement a function that takes a 2D integer matrix and an integer target. The matrix has the properties that each row is sorted in non-decreasing order, and the first integer of each row is greater than the last integer of the previous row. This allows us to treat the entire matrix as a single sorted array and perform binary search over it. Here's how you can adapt your approach:
Your current solution for the unknown size array is good, but please ensure you are solving the correct problem. For the 2D matrix problem, you should write a solution similar to the reference provided. VERDICT: NEEDS_IMPROVEMENT |
Completed Binary-Search-1 - Please review