The test case is so wrong, how


#1

Your submission failed for the following input:

A : [ "abbbaabbbabbbbabababbbbbbbaabaaabbaaababbabbabbaababbbaaabbabaabbaabbabbbbbababbbababbbbaabababba", "abaaabbbabaaabbbbabaabbabaaaababbbbabbbaaaabaababbbbaaaabbbaaaabaabbaaabbaabaaabbabbaaaababbabbaa", "babbabbaaabbbbabaaaabaabaabbbabaabaaabbbbbbabbabababbbabaabaabbaabaabaabbaabbbabaabbbabaaaabbbbab", "bbbabaaabaaaaabaabaaaaaaabbabaaaabbababbabbabbaabbabaaabaabbbabbaabaabaabaaaabbabbabaaababbaababb", "abbbbbbbbbbbbabaabbbbabababaabaabbbababbabbabaaaabaabbabbaaabbaaaabbaabbbbbaaaabaaaaababababaabab", "aabbbbaaabbaabbbbabbbbbaabbababbbbababbbabaabbbbbbababaaaabbbabaabbbbabbbababbbaaabbabaaaabaaaaba", "abbaaababbbabbbbabababbbababbbaaaaabbbbbbaaaabbaaabbbbbbabbabbabbaabbbbaabaabbababbbaabbbaababbaa", "aabaaabaaaaaabbbbaabbabaaaabbaababaaabbabbaaaaababaaabaabbbabbababaabababbaabaababbaabbabbbaaabbb" ]

Your function returned the following :

[3 5 ]

The expected returned value :

[1 ] [2 ] [3 5 ] [4 ] [6 ] [7 ] [8 ] //are you kidding me!!!


#2

what to do with this case…
i am also stucked
please help


#3

could only go through once I considered that every string is anagram with itself. When there are real anagrams present in the list, then the indexes will be “naturally” aggregated together if you’re using hashing


#4

Yes, I agree. Such a test case makes no sense at all.


#5

same error i got how can they give anagram to itself in testcase it will be valid for all string


#6

You can see that every position is atleast anagram with itself. So if it doesn’t found it’s anagram till it’s position then it will make a new key in the hashmap. And I think this is a better thing to do rather than just to map only those who have Anagrams with others. You will learn something new in this.


#7
  System.out.print(res[1][1]);

I can even access the element 5 in a matrix [[1],[3,5],[2],[6],[4],[7],[8]] using the above statement. But after I return this matrix res, the main function is returning final output as [[1],[2],[3],[4],[5],[6],[7],[8]];
I don’t understand what is happening in main function. Can somebody help me here ?