Problem Description
Given a sorted array A consisting of duplicate elements.
Your task is to remove all the duplicates and return the length of the sorted array of distinct elements consisting of all distinct elements present in A.
Note: You need to update the elements of array A by removing all the duplicates
First and only argurment containing the integer array A.
Input 1:
A = [1, 1, 2]
Input 2:
A = [1, 2, 2, 3, 3]
Output 1:
2
Output 2:
3
Explanation 1:
Updated Array: [1, 2, X] after rearranging. Note that there could be any number in place of x since we dont need it. We return 2 here.
Explanation 2:
Updated Array: [1, 2, 3, X, X] after rearranging duplicates of 2 and 3. We return 3 from here.
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 question? Checkout Sample Codes for more details.