hackerrank Piling Up!

来源:互联网 发布:网络赚钱方法大全 编辑:程序博客网 时间:2024/06/10 01:07

题目:https://www.hackerrank.com/challenges/piling-up/problem
题意:有点迷,大意就是是否从两边到中间逐渐减小
思路:list+sorted
其实最简单的是双指针模拟
代码:

'''-*- coding: utf-8 -*-@Author  : PlayerGuan@Time    : 2017/10/14 23:12@Software: PyCharm Community Edition@File    : main.py'''from collections import dequeT = int(input())for case in range(T):    n = int(input())    ls = list(map(int,input().split()))    pos = ls.index(min(ls))    left = ls[:pos]    right = ls[pos:]    if left == sorted(left,reverse=True) and right == sorted(right):        print("Yes")    else:        print("No")
原创粉丝点击