Code Room
Code reviewHardcr-g455
Subject Integer overflowLevel Senior–Staff~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Review this Java polynomial string hash used to shard keys across `n` backends.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewjava
int shard(String key, int n) {    int h = 0;    for (int i = 0; i < key.length(); i++) {        h = h * 31 + key.charAt(i);    }    return h % n;}
Run or narrate your approach, then ask the coach.