Question DSA-HASH-0011
MediumWhat is the output of this code?
nums = [100, 4, 200, 1, 3, 2]
s = set(nums)
best = 0
for x in s:
if x - 1 not in s:
y = x
while y + 1 in s:
y += 1
best = max(best, y - x + 1)
print(best)
- A.
5
- B.
2
- C.
Sign up free to see the answer and a step-by-step explanation.