Shawngbk / Leecode

Questions of Leecode
0 stars 0 forks source link

26. Remove Duplicates from Sorted Array #6

Open Shawngbk opened 7 years ago

Shawngbk commented 7 years ago

public class Solution { public int removeDuplicates(int[] nums) { if(nums.length == 0) return 0; int count = 1; for(int i = 1; i < nums.length; i++) { if(nums[i] == nums[i-1]) { continue; } else { nums[count] = nums[i];; count ++; } } return count; } }

http://www.2cto.com/kf/201411/356824.html