Why is this code giving segmentation fault?

Hello @015itachiuchiha,

Your code is facing TLE.
I have corrected your code:


Refer to comments for better understanding.

Hope, this would help.
Give a like if you are satisfied.