STRANGE LEETCODE!! My code give correct solution with "Run Code" but gives Wrong Answer on "Submit Solution"


  • 0
    G

    Strange behavior in leetcode.
    I am trying to run my code for the following test case:
    [0,0,1,1,2,3,4]
    It works fine when I just "Run Code" but fails on "Submit Answer".
    Does anybody have any suggestions?

    My Code:

            int j=0;
            for(int i=0;i<nums.size();++i)
            {
                nums[j++]=nums[i];
                if(i<nums.size() && nums[i]==nums[i+1])
                {
                    nums[j++]=nums[i];
                    while(i<nums.size() && nums[i]==nums[i+1])
                        i++;
                }
            }
            return j;
    

    Screenshot
    alt text


Log in to reply
 

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