Interview Task. Revert string in smart way