Here is the interview question prompt, presented for reference.
Given a non-decreasing sorted array of integers num, we have eliminated all the duplicated elements so that each element should be unique in the array. The relative arrangement of the elements must remain unchanged.
Let's take an example of a sorted integer array num = [1, 2, 3, 3, 4, 4, 5, 6, 6, 6, 8, 8]
. Our function will return the length of the array = 8, and the resultant output of the given array after removing the duplicate element will result = [1, 2, 3, 4, 5, 6, 8]
.

Let's take another example of a sorted integer array num = [1, 2, 2, 3, 4, 4, 4, 5, 5]
. Our function will return the length of the array = 5, and the resultant output of the given array after removing the duplicate element will be the result = [1, 2, 3, 4, 5]
.

Given a sorted array, develop a program to eliminate duplicate elements to ensure that there is only a single instance of each element. - We have to return the length of the array and the resultant array containing a single instance of each element present in the array.
num
, is sorted in non-decreasing order.num > 0
You can see the full challenge with visuals at this link.
Challenges • Asked about 1 year ago by Jake from AlgoDaily
This is the main discussion thread generated for Remove Duplicates from Sorted Array (Main Thread).