LeetCode – Remove Duplicates from Sorted Array II (Java)

Follow up for “Remove Duplicates“: What if duplicates are allowed at most twice? For example, given sorted array A = [1,1,1,2,2,3], your function should return length = 5, and A is now [1,1,2,2,3]. So this problem also requires in-place array manipulation. Java Solution 1 We can not change the given array’s size, so we only … Read more