For those who are facing Overflow/TLE


#1

Don’t do (mid * mid)>a logic because mid*mid definitely will lead to overflow and TLE because of wraparound so do mid>a/mid . To make sure mid doesn’t become zero intialise start=1 and end=a.
so mid=(start+end)/2


#2

thank you so bro,for this


#3

I think we can solve this by declaring mid as long variable which can overrides overflow error


#4

Thank you sir i got struct at it.


#5

Thanks man, I wouldnt have realised it was an overflow error


#6

I would have a taken a lot of time for me to realise. After seeing comment, I realised early and follow it.


#7

Thanks :slight_smile:


#8

Can you explain the logic behind it . Or provide some reference behind it .


#9

@ajay-unni_596 or use long int with (mid*mid)>a logic will get submitted


#10

Thank you so much brother.


#11

Bro.I know it is causing overflow but thanks for posting it bro.