Here is my solution in C, but leetcode compiler saying wrong for [1,1,2] input.


  • 0
    T
    int removeDuplicates(int* nums, int numsSize) {
        
        int i, count=numsSize, temp=*(nums);
        for(i=1;i<numsSize;i++){
            
            if(temp== *(nums+i)){
                count--;
            }
            else
                temp = *(nums+i);
        }
        
        return count;
    }

Log in to reply
 

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