first_num
and second_num
to a very large number (e.g., float('inf')
in Python).n
in the array nums
.n
is less than first_num
, set first_num
to n
.n
is greater than first_num
and less than second_num
, set second_num
to n
.n
is greater than second_num
, return true
as we have found the triplet.true
, return false
as no triplet exists.