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].
Naive Approach
Given the method signature "public int removeDuplicates(int[] A)", it seems that we should write a method that returns a integer and that's it. After typing the following solution:
Read full article from LeetCode – Remove Duplicates from Sorted Array II (Java)
No comments:
Post a Comment