Java solution beats 85% solutions


  • 0
    J
         int t=0;
         int max=0;
           
           for(int i=0;i<nums.length;i++) {
                     if(nums[i]==0)
                             t=0;
                    else     t++;
                    if(t>=max)
                             max=t;
                  }
        return max;

Log in to reply
 

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