Code Room
Code reviewMedium
Question
Review this Java validation routine.
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.
Learn the concepts
public boolean allValid(List<String> tokens, Set<String> dictionary) { for (int i = 0; i < tokens.size(); i++) { String normalized = tokens.get(i).trim().toLowerCase(); List<String> dict = new ArrayList<>(dictionary); // copy for binarySearch Collections.sort(dict); if (Collections.binarySearch(dict, normalized) < 0) { return false; } } return true;}Run or narrate your approach, then ask the coach.