Обновлено: 2024-03-12
1 мин
Содержание
class Solution:
def maximumLength(self, nums: List[int]) -> int:
cnt = Counter(nums)
res = cnt[1] - (cnt[1] % 2 ^ 1)
del cnt[1]
for x in cnt:
t = 0
while cnt[x] > 1:
x = x * x
t += 2
t += 1 if cnt[x] else -1
res = max(res, t)
return res