Home > Reflections | ⏮️ ⏭️
2024-07-02
🏋️ Coding Practice
26. Remove Duplicates from Sorted Array
Given an integer array
nums
sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements innums
.
Consider the number of unique elements ofnums
to bek
, to get accepted, you need to do the following things:
- Change the array
nums
such that the firstk
elements ofnums
contain the unique elements in the order they were present innums
initially. The remaining elements ofnums
are not important as well as the size ofnums
.- Return
k
.
🪞 Reflections
- < 14 minutes is good
- no bugs is pretty good
- the test case may have been a bit longer than necessary, but it got the coverage we needed and we finished in time
- testing gave confidence in the correct code
- I remember planning this problem in the past without coding the solution
- I didn’t reference my old planning notes, but I did remember the approach
- Planning took about the same amount of time this time as it did last time