Untitled
Anonymous
python
02/12/2026 5:48 PM
704 B
9
Indexable
from collections import defaultdict
n = int(input())
arr = []
for i in range(n):
arr.append(int(input()))
print(arr)
lcs = 0
present,checked = defaultdict(int),defaultdict(int)
for nums in arr:
present[nums] = True
for nums in arr:
if nums not in checked and nums - 1 not in present:
cc = 0
start = nums
while present[start]:
cc += 1
checked[start] = True
start = start + 1
lcs = max(lcs,cc)
print(lcs)
Editor is loading...
Leave a Comment