You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Excellent implementation that matches the optimal approach
Clean and readable code with appropriate comments
Correctly handles edge cases (empty arrays)
Proper use of three-pointer technique from the end
Areas for minor improvement:
Could add a brief comment explaining why we don't need to copy remaining elements from nums1 (they're already in place)
The while loop condition p1 >= 0 && p2 >= 0 is correct, but for clarity, you could note that when only p2 remains, we must copy from nums2 (since nums1's remaining elements are already in their final positions)
The solution is solid and production-ready. Well done!
VERDICT: PASS
Search 2D sorted matrix II (RemoveDuplicatesFromSortedArray2.java)
Wrong Problem: The submitted code solves a completely different problem. The "Search 2D Matrix II" problem requires searching for a target in a 2D matrix where rows and columns are sorted, not removing duplicates from a sorted array.
No Comparison Possible: Since the solution doesn't address the given problem, we cannot meaningfully compare it to the reference solution in terms of time/space complexity for this specific task.
Code Quality (for wrong problem): The code for "Remove Duplicates II" is actually well-written - it uses the two-pointer technique correctly, handles the count tracking properly, and is readable. However, this doesn't help with the assigned problem.
What the student should have done: For the Search 2D Matrix II problem, a common efficient approach is:
Start from top-right corner (or bottom-left)
If current element equals target, return true
If current element > target, move left
If current element < target, move down
This gives O(m+n) time complexity
VERDICT: NEEDS_IMPROVEMENT
Edit and Remove Duplicates in an array (Search2DMatrix2.java)
The submitted code solves a different problem (Search 2D Matrix II) and does not address the Edit and Remove Duplicates problem at all
No attempt was made to implement the duplicate removal logic with the constraint of allowing at most 2 occurrences per element
No in-place modification logic is present
Please ensure you submit the correct solution for the problem you are attempting to solve
VERDICT: NEEDS_IMPROVEMENT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://leetcode.com/problems/search-a-2d-matrix-ii/
https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/
https://leetcode.com/problems/merge-sorted-array/