Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

using deque to make a list

python
from collections import deque
def check(d):
    while d:
        big = d.popleft() if d[0]>d[-1] else d.pop()
        if not d:
            return "Yes"
        if d[-1]>big or d[0]>big:
            return "No"
    
for i in range(int(input())):
    int(input())
    d = deque(map(int,input().split()))
    print(check(d))
Source by www.thepoorcoder.com #
 
PREVIOUS NEXT
Tagged: #deque #list
ADD COMMENT
Topic
Name
7+6 =