Code Room
Code reviewHardcr-g468
Subject Edge casesLevel Mid–Senior~16 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this C++ loop meant to compare adjacent elements of a vector (it should do nothing for an empty vector).

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
for (size_t i = 0; i < v.size() - 1; i++) {    if (v[i] > v[i + 1]) report(i);}
Run or narrate your approach, then ask the coach.