Skip to content

Instantly share code, notes, and snippets.

@m2kar
Created September 8, 2019 13:36
Show Gist options
  • Save m2kar/13a2290bb0157f76dd1ee1d0d2a641c0 to your computer and use it in GitHub Desktop.
Save m2kar/13a2290bb0157f76dd1ee1d0d2a641c0 to your computer and use it in GitHub Desktop.
字节跳动笔试题目 机器人向前看
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
@m2kar
Copy link
Author

m2kar commented Sep 8, 2019

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment