Odd badge ID
An office turnstile logs a badge ID on every entry and every exit. At closing time, everyone has badged in and out — appearing an even number of times — except exactly one person who is still inside and appears an odd number of times. Given the day's log of badge IDs (non-negative integers, in any order), return the ID of the person still inside, using O(1) extra space. For example, [4, 7, 4] returns 7.
Implement
find_inside_badge(log: list[int]) → intExamples
in
[[4,7,4]]out7in
[[10,20,10,30,20]]out30What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 10 min
solution.py
InputExpectedGot
[[4,7,4]]7not run yetsample[[10,20,10,30,20]]30not run yetsample