mercredi 16 septembre 2020

How much time does a 'if condition' takes in java? [duplicate]

I was solving a Linked List question on GeeksForGeeks and it got TLE(Time Limit Exceeded)

And then I found a useless line in my code

if(fast==null||fast.next==null) return fast;

It was a recursive solution My code was working very fine in my IDE But removing the above line made it almost 2 sec fast and thus it got accepted

So anyone can explain me how much time it cost for a 'if' statement

Aucun commentaire:

Enregistrer un commentaire