Getting Runtime error in Test 0 and test3

I have implemented the code for this problem but was getting run error on test 0 and test 3. Please help.

can you share your code?

Here is my code: https://ideone.com/EYaYjY