Implement merge-in-place and group cyclic-equivalent strings | Meta Interview Question