Skip to content

Completed s30 Binary-Search-2#2355

Open
prenastro wants to merge 1 commit into
super30admin:masterfrom
prenastro:master
Open

Completed s30 Binary-Search-2#2355
prenastro wants to merge 1 commit into
super30admin:masterfrom
prenastro:master

Conversation

@prenastro

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Find First and Last Position of Element in Sorted Array (findpeakeleindex.py)

Strengths:

  • The binary search implementation is correct and well-structured
  • Uses proper variable naming (left, right, mid)
  • Includes time and space complexity comments
  • Handles edge cases properly (single element would return 0)

Areas for Improvement:

  • This solution solves the wrong problem entirely. The submitted code is for "Find Peak Element" not "Find First and Last Position of Element in Sorted Array"
  • For the actual problem, you need to implement two separate binary searches: one to find the first occurrence and one to find the last occurrence of the target
  • The solution should return a vector with two values [firstPosition, lastPosition] instead of a single index
  • Consider reviewing the problem statement carefully before selecting which problem to solve

For the actual problem, the approach should be:

  1. Use binary search to find the leftmost (first) position where target appears
  2. Use binary search to find the rightmost (last) position where target appears
  3. Return [-1, -1] if target is not found

VERDICT: NEEDS_IMPROVEMENT


Find Minimum in Rotated Sorted Array (firstandlastposinsortedarr.py)

  • Strengths: The solution shows good understanding of binary search for range finding, with proper handling of left/right bias, clean code structure, and correct time/space complexity for its target problem.
  • Major Issue: This is the wrong problem entirely. The solution should find the minimum element in a rotated sorted array, not search for a target's range.
  • Missing: No attempt to identify the pivot point or minimum element using the rotated array properties.

VERDICT: NEEDS_IMPROVEMENT


Find Peak Element (mininrotsortedarr.py)

Strengths:

  • The code is clean and well-structured
  • Comments are present explaining the logic
  • Time and space complexity are documented
  • Handles edge cases (duplicates) appropriately for its intended problem

Areas for Improvement:

  • The student has submitted code for an entirely different problem
  • The filename and problem solved don't match the "Find Peak Element" problem
  • The solution doesn't check if an element is greater than both neighbors (the core requirement of peak element)
  • No binary search logic for finding peaks (comparing with both left and right neighbors)

What was needed:

  • A function named findPeakElement (not findMin)
  • Logic to check if nums[mid] > nums[mid-1] AND nums[mid] > nums[mid+1]
  • Binary search that moves toward the ascending slope to find a peak

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