Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.
1. You are given an array of Strings.
2. You have to group all strings that belong to the same shifting sequence.
3. A string is "shifted" when we change each letter of a string to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:
"abc" -> "bcd" -> ... -> "xyz"
4. For example:
Input: ["abc", "bcd", "acef", "xyz", "az", "ba", "a", "z"],
Output:
[
["abc","bcd","xyz"],
["az","ba"],
["acef"],
["a","z"]
]
5. main takes input a String array from the users.
6. This is a functional problem.
7. You have to complete the groupStrings function. It takes as input a String array. It return a list of list of strings of strings with same shifting sequence grouped together.
8. Don't change the code of main.
Input Format
First line takes input N, the length of the string array. Second line takes input N space separated strings representing the elements of the array. Input is handled for you.
Output Format
strings grouped together. Output is handled for you.
Constraints
N/A
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
8 abc bcd acef xyz az ba a z
Output
abc bcd xyz a z az ba acef