data-structures · intermediate · ~15 min
Turn a string into a reproducible hash value.
Implement the classic djb2 hash: unsigned long djb2(const char *s) starting at 5381 and, for each byte, computing hash = hash * 33 + byte.
unsigned long djb2(const char *s) {
/* TODO */
return 5381;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.