Skip to content

Completed Binary Search 2#2354

Open
MrunaliVaidya98 wants to merge 2 commits into
super30admin:masterfrom
MrunaliVaidya98:master
Open

Completed Binary Search 2#2354
MrunaliVaidya98 wants to merge 2 commits into
super30admin:masterfrom
MrunaliVaidya98:master

Conversation

@MrunaliVaidya98

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Find First and Last Position of Element in Sorted Array (findPeakElement.java)

  • The code correctly implements binary search, but for a completely different problem
  • The binary search implementation itself is clean and follows best practices (using low + (high-low)/2 to avoid overflow)
  • Good variable naming and code structure
  • However, the student appears to have submitted code for the wrong LeetCode problem
  • To solve the actual problem, the student needs to implement two binary searches: one for the first occurrence and one for the last occurrence of the target

VERDICT: NEEDS_IMPROVEMENT


Find Minimum in Rotated Sorted Array (findMin.java)

Strengths:

  • Correct binary search logic for finding minimum in rotated array
  • Efficient O(log n) time and O(1) space complexity
  • Clean and concise implementation
  • Proper handling of all test cases

Areas for Improvement:

  • Follow Java naming conventions: class names should start with uppercase (Solution)
  • Add comments to explain the logic, especially the key insight about comparing nums[mid] with nums[right]
  • Consider adding a check for edge cases like empty arrays if the problem constraints allowed them

VERDICT: PASS


Find Peak Element (searchRange.java)

  1. Read the problem carefully: You submitted a solution for a completely different problem. The "Find Peak Element" problem requires finding an element greater than its neighbors, not searching for a target value.

  2. Fix syntax errors: "pblic" should be "public" - this is a basic typo that would cause compilation failure.

  3. Fix method signatures: The problem asks for a single index return, but your solution returns an int array.

  4. Fix logic errors: In findLast, the condition else if(nums[mid]<target) is redundant and incorrect. Also, methods don't return values in all paths.

  5. Study the correct approach: For peak element finding, use binary search comparing nums[mid] with nums[mid+1] to determine which direction to search.

VERDICT: NEEDS_IMPROVEMENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants