MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / getHash

Method getHash

49. Group Anagrams/Solution.cpp:40–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38 }
39
40 unsigned long getHash(string str) {
41 int cnt[26] = {0};
42 for (char c : str) {
43 cnt[c - 'a'] ++ ;
44 }
45 unsigned long res = 0;
46 for (int i = 0; i < 26; i++) {
47 res += cnt[i] * pow(prime, i);
48 }
49 return res;
50 }
51
52
53 // O(1)

Callers

nothing calls this directly

Calls 1

powFunction · 0.85

Tested by

no test coverage detected