expert
Challenge: a consistent hashing ring
Implement this from the stub. Hidden tests grade the behaviour you write, not the comments you leave.
Challenge: A Consistent Hashing Ring
/** Deterministic 32-bit FNV-1a — given, not the exercise. */
export function fnv1a(text: string): number {
let hash = 0x811c9dc5
for (let i = 0; i < text.length; i++) {
hash ^= text.charCodeAt(i)
hash = Math.imul(hash, 0x01000193)
}
return hash >>> 0
}
export class ConsistentHash {
addNode(id: string): void {
// Your implementation here
}
removeNode(id: string): void {
// Your implementation here
}
nodeFor(key: string): string {
// Your implementation here
}
}challenge — implement from scratchCtrl+↵ submits · Ctrl+Shift+↵ runsstarter code