Chewy Interview Question

How did you provide simple solution to complex problem? Hackerrank rollingString problem