I implemented the code on hackerblocks and it was failing a single test case. After debugging for a while, I used a double instead of a float variable, and it worked! How does this happen? How does it determine the time limits for a code?
Double or Float?
This is for the birthday paradox problem
Difference between float and double is that of precision. Float is appx. 7 digits while double is 15 digits. Float was used mainly for saving memory back in time because of scarcity of memory, which now obviously is no longer a problem. So, in future try using double rather than float.
Also for as why does float gives WA, it could probably mean that the precision required by the problem isn’t satisfied by float. And moreover I don’t think using either would have much effect on time complexity of the code.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.