Problem 9: Unique Elements
You are given an array A of N elements. You have to make all elements unique, to do so in one step you can increase any number by one.
Find the minimum number of steps.
1 <= N <= 105
1 <= A[i] <= 109
The only argument given is an Array A, having N integers.
Return the Minimum number of steps required to make all elements unique.
A = [1, 1, 3]
A = [2, 4, 5]
We can increase the value of 1st element by 1 in 1 step and will get all unique elements. i.e [2, 1, 3].
All elements are distinct.
Note: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt?
- All submissions are automatically checked for plagiarism, and flagged solutions might not be counted towards the total score.
- Do not hesitate to discuss the solution with your batchmates, or take help from your Coach to build intuition.
- DO NOT move on from a problem until you have understood the approach very well.
- Plagiarism would defeat the purpose of learning a new pattern and concept.