Rotate String to get max binary number

My solution is giving the wrong answer for larger values of n.
Please, help

Problem link
My solution

Thank you.

Did you get the sol?
I tried but got TLE in one test case


here is my code