Coin Flip Question

Why is my answer wrong? Please help me to identify mistakes.Secondly,it is showing time limit exceeded.Why?
Here is my solution CodeChef: Practical coding for everyone

while flipping coins, in the loop of variable k, u have incremented i instead of k.
your time complexity is of O(nng*t), so come up with a getter solution.

1 Like

Thanks for same.I have updated my code.Here is the link to the solution CodeChef: Practical coding for everyone
It shows time limit exceeded.Why?How to optimize it?

Try and think of a better solution which takes less time. If you don’t know about time complexity, go and watch the 1st session of DSA series on youtube.

1 Like

Ok.Thanks

1 Like

There is a O(1) time solution to the problem, take pen-paper and just simulate the game.

1 Like