This exact problem is found on the Codeforces OJ on this link:
Its solution is also fully written on stack overflow on this link:
I found several people who blindly copied that code and got AC!. The reason I know this problem was on Stackoverflow was because I was the one who asked that question in 2015!!
Truly sorry for that,
We didn't expect this problem to be found on the another OJ, and also we didn't expect someone to just copy other people's solutions for the contest - That's not the meaning for the contest - we expect the users using our contest for practicing the interviews or algorithm.
Also, our contest will run anti-cheating system after the contest ended - so if someone cheats, we will find it and give him some punishment to ensure the fairness of the contest.
Have a nice weekend.
LeetCode Contest Team.