Could anyone tell me why my python code doesn't work?

  • 0
        i = 1
        while(len(nums) > i):
            if(nums[i-1] == nums[i]):
                del nums[i]
                i += 1
        return i

    when I run the code, the Notice: index out of range. But where?

Log in to reply

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