please check why testcase 2 is failing.
testcase 2 : 50 true 290 true 23 false false false true 78 true 66 false false false
10 true 20 true 40 false false true 50 false false true 30 true 60 false false true 73 false true 88 false false
output of my code is false and correct answer is false