Code Room
Code reviewHardcr-g271
Subject Boundary conditionsLevel Senior–Staff~20 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this C++ routine that finds the max of a sensor reading buffer.

A dropped sensor occasionally writes a NaN into the buffer. Downstream code gates an actuator when `maxReading(v)` exceeds a threshold.

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 reviewcpp
double maxReading(const std::vector<double>& v) {    double best = -std::numeric_limits<double>::infinity();    for (double x : v) {        if (x > best) {            best = x;        }    }    return best;}
Run or narrate your approach, then ask the coach.