Can anybody tell me what's wrong with this?

  • 0

    I'm not sure how this is incorrect, it's not identical to the solution in terms of syntax but it should have the same functionality:

            int length = 1;
            int prev = nums[0];
            for (int i=1; i < nums.length; i++){
                if (nums[i] != prev){
                    prev = nums[i];
          return length;

Log in to reply

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