Back to course home
0% completed
Vote For New Content
Easier to understand solution(JAVA)
Ankur Masih
Jun 14, 2023
public int[] removeDuplicate(int[] arr) { if (arr.length < 2) { return arr; } int l = 0; int r = 1; while (r < arr.length) { if (arr[l] != arr[r]) { arr[++l] = arr[r]; } r++; } return Arrays.copyOf(arr, l + 1); }
0
0
Comments
Comments
On this page
Problem Statement
Try it yourself