Remove Duplicates From Sorted Array In Place
Reported by candidates from Get My Parking's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The detail that matters in this Get My Parking question is that the array arrives already sorted, and you have to compact it in place. It was reported in September 2026, and the report calls it an easy coding question solved in a shared doc. That's the whole game: two pointers, one pass, no extra array. Easy problems still sink people who overthink them or panic when the interviewer watches them type. If you have this OA coming, expect a warmup that rewards clean code over cleverness. StealthCoder is the safety net running invisibly during the live OA if your mind goes blank on the pointer logic.
The problem
You are given an integer array nums sorted in nondecreasing order. Modify it in place so that each distinct value appears exactly once and the retained values stay in sorted order. Return an array containing exactly the compacted prefix. Extra capacity after that prefix may be left unchanged. What the interview report shared The interviewer asked an easy coding question: remove duplicate elements in a sorted array in place. The candidate solved it in a shared Google Doc. Function removeDuplicates(nums: int[]) → int[] Examples Example 1 nums = [1,1,2] return = [1,2] The sorted values are 1, 1, and 2. After in-place compaction the unique prefix is [1,2]. Example 2 nums = [0,0,1,1,1,2,2,3,3,4] return = [0,1,2,3,4] Adjacent duplicates are overwritten so each retained value appears once. The compacted prefix is [0,1,2,3,4]. Example 3 nums = [] return = [] An empty array has no values to retain, so the compacted prefix is empty. Constraints 0 <= nums.length <= 10^5. -10^9 <= nums[i] <= 10^9. nums is sorted in nondecreasing order.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that sorted means duplicates sit next to each other. Keep a write index starting at 0 (or 1). Walk the array with a read index. Whenever nums[read] differs from the last kept value, write it at the write index and advance. When you finish, the first k slots hold the unique values in order. Return that prefix, like nums[0:k] in Python or a copy of the first k elements. The common pitfalls: comparing against the wrong neighbor, forgetting the empty array case (length 0 is allowed), and returning the count when this version asks for the compacted array. Don't use a set. It breaks the in-place requirement and wastes the sorted guarantee. With n up to 10^5 this runs in O(n) time and O(1) extra space. If you freeze mid-OA, StealthCoder gives you the two-pointer solution in real time so you can confirm your edge cases.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Remove Duplicates From Sorted Array In Place cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as remove duplicates from sorted array. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Get My Parking's OA.
Get My Parking reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Remove Duplicates From Sorted Array In Place FAQ
How hard is the Get My Parking remove duplicates question really?+
It's easy. The report from September 2026 labeled it an easy coding question. One pass with two pointers solves it. The risk isn't difficulty, it's sloppy edge cases like an empty array or an array of all identical values.
What's the trick to solving it in place?+
Use a read pointer and a write pointer. Since the array is sorted, duplicates are adjacent. Only write a value when it differs from the last value you kept. Everything before the write pointer at the end is your unique, sorted result.
Do I return a count or an array here?+
This version asks you to return an array containing exactly the compacted prefix, not just the count. So after compaction, slice or copy the first k elements. Read the prompt carefully, since the classic version returns only k.
Can I just use a set to dedupe?+
You could get the right output, but it ignores the in-place requirement and the sorted input. A set also risks losing order in some languages. The two-pointer approach is shorter, uses constant extra space, and matches what the interviewer expects.
How do I prepare for this in 48 hours?+
Write the two-pointer solution from memory twice. Then test it on an empty array, a single element, all duplicates, and no duplicates. That covers nearly every failure case. Spend the rest of your time on other array and pointer patterns.