Write an algorithm to find a duplicate numbers in an array. Also display the location of the duplicate numbers. You are free to assume the size of the array and the number of duplicate numbers. Explain the algorithm with an example.
Answers
Answered by
0
Answer:
E.g Input: {4, 8, 4, 1, 1, 2, 9} Output: {4, 8, 1, 2, 9, ?, ?}
One caveat is that the expected algorithm should not required the array to be sorted first. And when an element has been removed, the following elements must be shifted forward as well. Anyway, value of elements at the tail of the array where elements were shifted forward are negligible.
Update: The result must be returned in the
Similar questions