Answers for "c++ the hash function with 31 const"

C++
0

c++ the hash function with 31 const

int hashFunction(string key) {
    int hashCode = 0;
    for (int i = 0; i < key.length(); i++) {
        hashCode += key[i] * pow(PRIME_CONST, i);
    }
    return hashCode;
}
Posted by: Guest on April-18-2022

Browse Popular Code Answers by Language