Skip to content

Two-pointers-2#1787

Open
hiteshmadapathi wants to merge 9 commits into
super30admin:masterfrom
hiteshmadapathi:Summer2026
Open

Two-pointers-2#1787
hiteshmadapathi wants to merge 9 commits into
super30admin:masterfrom
hiteshmadapathi:Summer2026

Conversation

@hiteshmadapathi
Copy link
Copy Markdown

No description provided.

@super30admin
Copy link
Copy Markdown
Owner

Merging of 2 arrays (Problem1.py)

The code quality itself is good - it's well-structured, properly commented, and follows clean coding practices. The algorithm correctly solves the "Remove Duplicates II" problem with O(n) time and O(1) space complexity. However, this is not the problem that was assigned. The student appears to have submitted code for a different problem, possibly from another practice session or a different LeetCode problem.

To improve:

  1. Ensure you're working on the correct problem - verify the problem statement before coding
  2. The merge problem requires two pointers starting from the end (or beginning) of both arrays
  3. Compare elements from nums1 and nums2 and place them in the correct position in nums1

VERDICT: NEEDS_IMPROVEMENT


Search 2D sorted matrix II (Problem2.py)

  1. Wrong Problem: The submitted solution solves "Merge Sorted Array" but the problem requires "Search 2D sorted matrix II". These are completely different problems requiring different approaches.

  2. For the Intended Problem (Merge Sorted Array): If this was the intended problem, the solution is correct and well-implemented:

    • Uses two-pointer technique from the end (optimal approach)
    • Handles edge cases properly
    • Time complexity O(m+n) is optimal
    • Space complexity O(1) is optimal
  3. For the Actual Problem (Search 2D Matrix II): The reference solution uses binary search on each row (O(m log n)), but a more optimal approach exists using the "top-right corner" or "bottom-left corner" strategy that starts from a corner where you can eliminate either a row or column in each step, achieving O(m+n) time complexity.

VERDICT: NEEDS_IMPROVEMENT


Edit and Remove Duplicates in an array (Problem3.py)

  • Major Issue: You have submitted a solution for the wrong problem entirely. The problem you were given asks you to remove duplicates from a sorted array so that each element appears at most twice, while your solution solves a matrix search problem.
  • Understanding: Please ensure you read and understand the problem requirements carefully before implementing a solution.
  • Next Steps: To solve the actual problem (Remove Duplicates from Sorted Array II), you need to:
    1. Iterate through the sorted array
    2. Keep track of how many times each element has appeared consecutively
    3. Only write elements to the result position if they've appeared fewer than twice
    4. Return the count of valid elements

Your solution demonstrates good coding skills for the matrix search problem (clear variable names, efficient O(m+n) algorithm, O(1) space), but it does not solve the assigned problem.

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