Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Why do we need the extraNumbers set?

Eric C

Sep 11, 2025

In the Python solution, it uses the extraNumbers set to keep track of additional numbers that are already part of the array. However, instead of the check:

if candidateNumber not in extraNumbers

can't we just check:

if candidateNumber not in nums ?

0

0

Comments
Comments
G
gentlerainsky 24 days ago

Item lookup in set (extraNumbers) is O(1) while it is O(N) in list (nums).

On this page