Simple java solution


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

    }


Log in to reply
 

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