Bug Report on wrong system expected result


  • 0
    W

    My code:

    class Solution {
    public:
        bool increasingTriplet(vector<int>& nums) {
    	if (nums.size() < 3)
    		return false;
    
    		for (size_t i = 0; i<nums.size()-2; i++)
    		{
    			if (nums[i]<nums[i + 1] && nums[i + 1] < nums[i + 2])
    					return true;
    		}
    		return false;
    }
    };
    

    Testing array:
    [5,1,5,5,2,5,4]
    The real expected result:
    false

    The system expect result:
    true

    there is no triplet increasing in this array, the system expected result is wrong. please fix this.

    or let me know if I've done something silly.


  • 3
    Z

    Sorry I think you misunderstanded this question. this question is not mean to find a continuous three increasing elements. This question wants you to find whether there are 3 elements that are increasing.

    For your case, [5,1,5,5,2,5,4] if i = 1, j = 4, k = 5. then a[i] < a[j] < a[k](1 < 2 < 5). So the expected answer is ture. i,j,k are not necessary to be continuos, only need to satisfy that i < j < k.


  • 0
    W

    thank you @zzandliz


Log in to reply
 

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