-2

In various codes where time limit exceeded, by using while(t-- >0) instead of while(t--) code runs successfully. I don't know about while(t-- >0) , I read it somewhere in the codechef examples solution.

Nicol Bolas
  • 413,367
  • 61
  • 711
  • 904

1 Answers1

-1

In practice, they are equivalent. It's just a matter of taste. Some think that while(t-- > 0) is clearer than while(t--).

As long as t is not negative, the two are completely equivalent. But on the other hand, a negative t would most likely indicate a bug with a loop like that.

klutt
  • 28,260
  • 15
  • 48
  • 83