Look for constraints carefully while dealing partial points.
There could be some test cases where your answer do not give correct.
There are many hidden test cases, which are not shown.
Just to warn you, USE IDEONE properly.
Make ideone programs private or code at own computer.
Otherwise someone can copy your program and you might be penalized for plagiarism.