这是我不同意的部分:
在位置 [[[0],[1]],[[0],[2]],[[0],[3]],[[ 1],[2]],[[1],[3]]
和 [[2],[3]] 。
在位置 [[0,1],[1,2]],[[0,1],[2,3]] 和 [[1,2] 处有 3 个 [kk,kk] 形式的变位词],[2,3]] 。
在位置 [[0,1,2],[1,2,3]] 处有 1 个形式为 [kkk,kkk] 的变位词。
我认为解释不正确的原因是:
1- 形式 [kk,kk] 我们有更多的变位词 [[0,1],[0,2]],[[0,1],[0,3]],[[1,2] ,[1,3]]
2- 形式 [kkk,kkk] 我们有更多的变位词 [[0,1,2],[0,2,3]], [[0,1,2],[0,1,3] ] 等等。
是我理解错了还是作者写错了?
请注意,在他上面的解释中,他并没有只按顺序使用字谜,所以我想知道他为什么不使用我找到的字谜?
最佳答案
Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find the number of pairs of substrings of the string that are anagrams of each other.
您应该仔细阅读链接中给出的字谜定义。作者没有错误。
关于python - HackerRank 上的 SherlockAndAnagrams 算法解释错了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57444379/