Minimum Increment to Make Array Unique
A medium-tier problem at 60% community acceptance, tagged with Array, Greedy, Sorting. Reported in interviews at Coursera and 2 others.
Minimum Increment to Make Array Unique hits your assessment, and the trap is obvious: you think greedy sorting works, then you code it in 20 minutes and get a wrong answer on the third test case. Coursera, ZScaler, and PayPal have asked this. The problem looks simple on the surface. You have duplicates, you need to increment some of them until all values are distinct, and you want the minimum total increments. The real trick isn't what you do first. It's what you do after sorting. Most candidates miss the order of operations, waste time backtracking, and run out of buffer. If you hit this live and blank on the greedy choice, StealthCoder surfaces the working solution in seconds, invisible to the proctor.
Companies that ask "Minimum Increment to Make Array Unique"
Minimum Increment to Make Array Unique is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe pattern: sort the array, then iterate left to right. For each element, if it's not strictly greater than the previous one, increment it until it is. The trap is thinking 'just check if it's a duplicate and increment once.' That fails when you have clusters like [1, 1, 1] or [3, 3, 5, 5]. After sorting, you can't just fix the current element in isolation. You have to ensure every element is strictly greater than everything before it. The greedy choice is to increment as little as possible at each step, which means if the current element is less than or equal to the previous one, set it to previous plus one. This works because you're never creating a new conflict further down the line. The counting and array topics matter here because you might optimize with a frequency map instead of raw sorting, but the core insight remains: left-to-right pass enforces uniqueness with minimal cost.
Pattern tags
You know the problem.
Make sure you actually pass it.
Minimum Increment to Make Array Unique recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Increment to Make Array Unique interview FAQ
Is this really a medium, or is the acceptance rate of 60% misleading?+
The acceptance rate reflects that most people get the greedy idea quickly but flub the implementation or edge cases. The algorithm itself is medium-difficulty. The real gotcha is handling consecutive duplicates and ensuring strict inequality at every step, not just pairwise. That's where submissions fail.
Do I need a frequency map or is sorting enough?+
Sorting alone works and is simpler. You iterate once, and if current is less than or equal to previous, you increment current to previous plus one and add the difference to your answer. No extra data structure needed. Frequency maps are an optimization for sparse or large ranges, but they're overkill here.
What's the common mistake that burns candidates on this problem?+
Trying to increment only duplicates in the original array, or incrementing by one at a time in a loop instead of jumping straight to the required value. Both lead to wrong answers or timeout. The fix: sort first, then one pass left to right, jumping to previous plus one when needed.
How does the Greedy topic actually apply to this problem?+
Greedy here means: at each position, make the smallest valid choice (increment as little as possible) without blocking future choices. Since you're sorted, incrementing to previous plus one is always safe and never creates a worse state downstream. It's locally optimal and globally optimal.
Is this problem still asked at PayPal and ZScaler, or is it outdated?+
It's in the recent report for all three companies listed. The pattern is foundational enough that it stays in rotation. The problem tests sorting discipline and greedy reasoning, skills that don't go out of style in technical interviews.
Want the actual problem statement? View "Minimum Increment to Make Array Unique" on LeetCode →