PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import deque
def checkGreater(c):
right_most = c[-1]
left_most = c[0]
if right_most>= left_most:
return(c.pop())
elif left_most > right_most :
return(c.popleft())
def check(cubes):
in_action_then = checkGreater(cubes)
while len(cubes):
if len(cubes) == 1 :
return ("Yes")
in_action_now = checkGreater(cubes)
if in_action_now <= in_action_then :
in_action_then = in_action_now
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run