Code RoomLock held during return
HardPrep Room Coding #1651

Lock held during return

Code reviewConcurrencySenior–Staff~26 min

Review this Go rate limiter.

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 26 min
Mark a line and say what kind of problem it is.0 findings
1func (l *Limiter) Allow(key string) bool {
2 l.mu.Lock()
3 count := l.counts[key]
4 if count >= l.max {
5 return false
6 }
7 l.counts[key] = count + 1
8 l.mu.Unlock()
9 return true
10}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.