黑客银行的神探密码算法解释错了吗?

2024-05-29 02:58:08 发布

您现在位置:Python中文网/ 问答频道 /正文

这里有一个链接:https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps

这是我不同意的部分:

在位置[[[0],[1]],[[0],[2]],[[0],[3]],[[1],[2]],[[1],[3]]处有6个形式为[k,k]的字谜

和[[2],[3]]。你知道吗

在位置[[0,1]、[1,2]]、[[0,1]、[2,3]]和[[1,2]、[2,3]]处有3个形式为[kk,kk]的anagram。你知道吗

在位置[[0,1,2],[1,2,3]]有一个形式为[kkk,kkk]的字谜。你知道吗

我认为解释不正确的原因是:

1-形式[kk,kk]我们有更多的anagrams[[0,1],[0,2]],[[0,1],[0,3]],[[1,2],[1,3]]

2-形式[kkk,kkk]我们有更多的anagrams[[0,1,2],[0,2,3]],[[0,1,2],[0,1,3]]等等。你知道吗

我是理解错了还是作者犯了错?你知道吗

请注意,在他上面的解释中,他没有按顺序使用字谜,所以我想知道为什么他没有使用我发现的字谜?你知道吗


Tags: andhttpscom链接wwwplaylist形式sherlock
1条回答
网友
1楼 · 发布于 2024-05-29 02:58:08

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.

你应该仔细阅读链接中给出的字谜的定义。作者没有犯错误。你知道吗

相关问题 更多 >

    热门问题