Бурдюгова Мария, 321 HalfMore 1465 | Stanislav HalfMore 1665 | ||||
---|---|---|---|---|---|
t | 1 | def find_majority_element(): | t | 1 | def find_majority_element(): |
2 | candidate = None | 2 | candidate = None | ||
3 | count = 0 | 3 | count = 0 | ||
4 | while (item := input()): | 4 | while (item := input()): | ||
5 | if count == 0: | 5 | if count == 0: | ||
6 | candidate = item | 6 | candidate = item | ||
7 | count = 1 | 7 | count = 1 | ||
8 | elif item == candidate: | 8 | elif item == candidate: | ||
9 | count += 1 | 9 | count += 1 | ||
10 | else: | 10 | else: | ||
11 | count -= 1 | 11 | count -= 1 | ||
12 | return candidate | 12 | return candidate | ||
13 | print(eval(find_majority_element())) | 13 | print(eval(find_majority_element())) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|