C# - reverse thru array start counter when you see a zero


  • 1
    public bool CanJump(int[] nums) {
        int min = 0;
        for (int i = nums.Length - 2; i >= 0; i--)
        {
            if (nums[i] > min) min = 0;
            else min++;
        }
        return min == 0;
    }

Log in to reply
 

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