# [discuss] some test cases may be missing

• here is my solution of `Find All Anagrams in a String`, checking prime numbers' sum instead of checking if arrays are equal:

``````public class Solution {
public List<Integer> findAnagrams(String s, String p) {
if (s.length() < p.length()) return new ArrayList<>();

int[] letters = new int[]{
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101
};
int standard = 0, cache = 0;
for (char c : p.toCharArray()) standard += letters[c - 'a'];
for (int i = 0; i < p.length() - 1; i++) cache += letters[s.charAt(i) - 'a'];

ArrayList<Integer> result = new ArrayList<>();
for (int j = 0; j <= s.length() - p.length(); j++) {
cache += letters[s.charAt(j + p.length() - 1) - 'a'];
cache -= letters[s.charAt(j) - 'a'];
}
return result;
}
}
``````

it got an AC(2018-11-01 14:04), but soon i realized it cannot pass this test:
"op"
"by"

i dont know how to add test cases either since prime numbers are too much, but just FYI. ;-P

• @liupangzi Thanks, I have added the test case. However, please do note that it is easy for one to modify their hash functions / prime number combinations and still get Accepted. And it is impossible to add all kinds of test that will prevent all of them from getting Accepted.

Please see the following post for similar idea:
https://discuss.leetcode.com/topic/65640/32ms-humorous-c-solution-it-s-true-o-n

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.