Code RoomProcessing time wraps negative
MediumPrep Room Coding #1909

Processing time wraps negative

Code reviewCode quality & reviewMid–Senior~16 min

Review this Java code that sums request durations (milliseconds) to compute total processing time over a day.

A busy shard handles tens of millions of requests per day.

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.

0:00 of about 16 min
Mark a line and say what kind of problem it is.0 findings
1long totalProcessingSeconds(List<Request> requestsToday) {
2 int totalMs = 0;
3 for (Request r : requestsToday) {
4 totalMs += r.durationMs(); // durationMs(): int, 0..~30000
5 }
6 long totalSeconds = totalMs / 1000L;
7 metrics.gauge("processing.total_seconds", totalSeconds);
8 return totalSeconds;
9}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.