Data Analyst Interview Question 2 - Python

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

from collections import Counter

arr = [2, 2, 4, 5, 9]
arr_counts = Counter(arr)
two_values = [key for key, value in arr_counts.items() if value == 2]
multiples_exist = {x for x in arr if x/2 in two_values}

if len(multiples_exist) == 0:
print('N/A')
else:
print(max(multiples_exist))

fardinahsan
join shbcf.ru