PY
py
1
2
3
4
5
6
7
8
9
10
11
# Boyer moore majority vote algo
def majv(s,e="",c=0):
for a in s:
e=e if c else a
c+=(a==e)<<1-1
return(e)
for t in["aaaeecacffgga","iibcidieiii","babcbdeb"
,"aaeratayaytea"]:
print(majv(t))
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run