1ms Java Solution


  • 0
    N
    public class Solution {
        public int removeDuplicates(int[] nums) {
            int i=0;
            int k=1;
            for(int j=2;j<nums.length;j++){
                if(nums[i]!=nums[j]){
                    i++;
                    k++;
                }
                nums[k]=nums[j];
            }
            return k+1;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.