Replace all PI doubt

In this question, though I have passed all the testcases, but the approach shown in the HINT which has been provided is very different, I just wanted to ask if my approach is correct or not, or do I need to do anything else.
Here’s my code: https://ide.codingblocks.com/s/83708

No , your approach is fine.