Problem with testcase


  • 0
    M

    Hey guy,

    today i tried to solve my first problem.

    But i do not get it.

    The Testcase [1,2,-10,-8,-7] expects to be true. But why? There are just 2 numbers > 0 so it cant be true?

    Maybe i dont get the problem right...

    My code:

    public class Solution {
    public boolean increasingTriplet(int[] nums) {
        for(int i = 0; i<nums.length; i++)
        {
            if(nums[i]>=0)
            {
            for(int j = i+1; j<nums.length; j++)
            {
                if(nums[j]>=0 && nums[i]<nums[j])
                {
                for(int k = j+1; k<nums.length; k++)
                {
                    if(nums[k]>=0 && nums[j]<nums[k])
                    {
                        return true;
                        
                    }
                }
                }
            }
            }
        }
    return false;
    }   
    }

  • 0
    M

    -10 < -8 < -7

    hence an increasing sequence of length 3


  • 0
    M

    Oh i know my mistake. Thank you


Log in to reply
 

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