Skip to content

Commit 8e458a6

Browse files
author
Ram swaroop
committed
added comments
1 parent 72c9c3b commit 8e458a6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/me/ramswaroop/strings/AnagramsTogether.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@
1111
*/
1212
public class AnagramsTogether {
1313

14+
/**
15+
* Prints all the anagrams together from the string
16+
* array {@param s}.
17+
*
18+
* @param s
19+
*/
1420
public static void printAnagramsTogether(String[] s) {
1521

22+
// each key holds all the indexes of a anagram
1623
HashMap<String, List<Integer>> hashMap = new HashMap<>();
1724

1825
for (int i = 0; i < s.length; i++) {
1926
char[] chars = s[i].toCharArray();
2027
Arrays.sort(chars);
21-
28+
2229
List<Integer> indexes = hashMap.get(String.valueOf(chars));
2330
if (indexes == null) {
2431
indexes = new ArrayList<>();

0 commit comments

Comments
 (0)