- Notifications
You must be signed in to change notification settings - Fork2.4k
Open
Description
Bug Report forhttps://neetcode.io/problems/remove-duplicates-from-sorted-array
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
This is my simplest proposed solution in Java for this problem:
class Solution { public int removeDuplicates(int[] nums) { Set<Integer> arraySet = new HashSet(); for (int num: nums){ arraySet.add(num); } return arraySet.size(); }}
The platform returns the solution is incorrect as follows:
Input:
nums=[1,1,2,3,4]
Your Output:
[1,1,2,3]
Expected output:
[1,2,3,4]
Tested it out in an IDE, the result is according to the expected output, as by definition a Set doesn't allow duplicated values.
Metadata
Metadata
Assignees
Labels
No labels