Created
September 8, 2019 13:36
-
-
Save m2kar/13a2290bb0157f76dd1ee1d0d2a641c0 to your computer and use it in GitHub Desktop.
字节跳动笔试题目 机器人向前看
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from logging import debug | |
import logging | |
# logging.basicConfig(level=logging.DEBUG) | |
n=int(input()) | |
sl=input() | |
l=[int(s) for s in re.split(r"\s",sl.strip("\n").strip(" "))] | |
# debug(f"n={n} l={l}") | |
nl=[0]*n | |
for xi,x in enumerate(l): | |
for yi in range(xi-1,-1,-1): | |
y=l[yi] | |
debug(f"xi={xi},yi={yi},x={x},y={y}") | |
if y>=x: | |
# debug(f"{xi} see {yi}") | |
nl[yi]+=1 | |
break | |
# debug(f"{nl}") | |
m=max(nl) | |
for nli,nln in enumerate(nl): | |
if nln==m: | |
print(l[nli]) | |
break |
Author
m2kar
commented
Sep 8, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment