249. Group Shifted Strings (Medium)