# Two different solutions in C, both accepted as best

• ``````//AC - 4ms;
bool increasingTriplet(int* nums, int size)
{
int first = INT_MAX, second = INT_MAX;
for(int i = 0; i < size; i++)
{
if(nums[i] <= first) first = nums[i]; //the equal condition here is quite essential;
else if(nums[i] <= second) second = nums[i];
else return true;
}
return false;
}

//AC - 4ms;
bool increasingTriplet(int* nums, int size)
{
int first = INT_MAX, second = INT_MAX;
for(int i = 0; i < size; i++)
{
if(nums[i] > second) return true;
else if(nums[i]>first) second = nums[i]<second? nums[i]:second; //make it as small as possible;
else first = nums[i]; //make it as small as possible;
}
return false;
}``````

• I think your answer is wrong. if the arry is [2,3,1,5]

• Which one you mean exactly? I re-checked both of them in the OJ and the answer is as expected. Something else wrong about it? Maybe you can point it out more specifically. Thanks in advance!

• I was wrong yesterday and really sorry about it.

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