Sobes.tech
Junior — Senior

Removing duplicate elements from an array

livecode

Task condition

An array of integers nums, sorted in ascending order, is given. The task is to remove all duplicate values by modifying the array in place so that each unique element appears only once. The order of remaining elements must be preserved. The function should return the number of unique elements, and the contents of the remaining part of the array beyond that are not important.

public int removeElement(int[] nums, int val) {
    
}