Code Room
Code reviewHardcr-g300
Subject Boxing overheadLevel Senior–Staff~22 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Java method that counts occurrences of each integer key in a high-volume stream of events.

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
Map<Integer, Integer> countKeys(int[] keys) {    Map<Integer, Integer> counts = new HashMap<>();    for (int k : keys) {        Integer cur = counts.get(k);        counts.put(k, cur == null ? 1 : cur + 1);    }    return counts;}
Run or narrate your approach, then ask the coach.