Created
May 21, 2018 23:32
-
-
Save Siyu-Lei/2dd05c9e4fee8e5badc2b759c67644cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public int removeDuplicates(int[] nums) { | |
int i = 0; | |
for (int n = 0; n < nums.length; n++) { | |
if(i < 2 || nums[n] > nums[i - 2]) { | |
nums[i++] = nums[n]; | |
} | |
} | |
return i; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment