PAST4F
from Fourth Algorithm Practical Skills Test
PAST4F
F - Parsing
AMBIGUOUS if the number of occurrences is the same compared to above or below.
code:python
def solve(N, K, SS):
from collections import Counter
c = Counter(SS).most_common()
K -= 1
ck, ckv = cK
if K > 0:
_, pv = cK - 1
if pv == ckv:
return "AMBIGUOUS"
if K < len(c) - 1:
_, pv = cK + 1
if pv == ckv:
return "AMBIGUOUS"
return ck
---
This page is auto-translated from /nishio/PAST4F using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.