Code RoomHigh water mark check-then-act
HardPrep Room Coding #2040

High water mark check-then-act

Code reviewConcurrencySenior–Staff~28 min

Review this Go high-water-mark tracker that records the largest latency seen, called from many request goroutines.

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 28 min
Mark a line and say what kind of problem it is.0 findings
1type HighWater struct {
2 max atomic.Int64
3}
4 
5func (h *HighWater) Observe(latencyNs int64) {
6 if latencyNs > h.max.Load() {
7 h.max.Store(latencyNs)
8 }
9}
10 
11func (h *HighWater) Max() int64 { return h.max.Load() }
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.