시니어
2026년 8월 19일버그를 찾아라: .NET
코드 한 조각. 버그를 찾거나, 버그가 없음을 증명하세요.
csharp
1using System.Collections.Generic;
2
3public class RequestCounter
4{
5 private readonly Dictionary<string, int> _counts = new();
6 private readonly object _lock = new();
7
8 public void Increment(string endpoint)
9 {
10 lock (_lock)
11 {
12 if (!_counts.ContainsKey(endpoint))
13 _counts[endpoint] = 0;
14 _counts[endpoint]++;
15 }
16 }
17
18 public int GetCount(string endpoint)
19 {
20 return _counts.TryGetValue(endpoint, out var count) ? count : 0;
21 }
22}문제가 되는 줄을 클릭하세요.
당신의 판단
하루 한 번. 제출하면 바로 정답이 표시됩니다.
연속 기록 유지하기
계정을 만들면 연속 기록을 유지하고 진행 상황을 추적할 수 있습니다.