896. Monotonic Array
An array is monotonic if it is either monotone increasing or monotone decreasing.
An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j].
Return true if and only if the given array A is monotonic.

Note:
1 <= A.length <= 50000-100000 <= A[i] <= 100000
class Solution(object):
def isMonotonic(self, A):
if (len(A) == 1):
return True target_list = []
for i in range(len(A)-1):
target_list.append(A[i+1]-A[i]) target_list_stored = sorted(target_list) for j in range(len(target_list_stored)):
if target_list_stored[0] <= 0 and target_list_stored[-1] <= 0:
return True
elif target_list_stored[0] >= 0 and target_list_stored[-1] >= 0:
return True
else :
return False
896. Monotonic Array的更多相关文章
- 896. Monotonic Array@python
An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is mono ...
- 【Leetcode_easy】896. Monotonic Array
problem 896. Monotonic Array solution1: class Solution { public: bool isMonotonic(vector<int>& ...
- [LeetCode] 896. Monotonic Array 单调数组
An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is mono ...
- LeetCode 896 Monotonic Array 解题报告
题目要求 An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is ...
- [LeetCode&Python] Problem 896. Monotonic Array
An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is mono ...
- 896. Monotonic Array单调数组
[抄题]: An array is monotonic if it is either monotone increasing or monotone decreasing. An array A i ...
- LeetCode 896. Monotonic Array
原题链接在这里:https://leetcode.com/problems/monotonic-array/ 题目: An array is monotonic if it is either mon ...
- 【LeetCode】896. Monotonic Array 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
- LeetCode 896. 单调数列(Monotonic Array)
896. 单调数列 896. Monotonic Array 题目描述 如果数组是单调递增或单调递减的,那么它是单调的. 如果对于所有 i<=j,A[i]<=A[j],那么数组 A 是单调 ...
随机推荐
- 监控数组与foreach绑定-Knockout.js
html: <h2>Your seat reservations</h2> <table> <thead> <tr> ...
- Django (十一) 项目部署 2
阿里云项目部署 ( 如果xshell连接不上阿里云: 解决方法: 1, 在淘宝IP地址库查看当前IP: http://ip.taobao.com/ 2, 点击进入:安全(云盾) -> 安骑士(服 ...
- codechef FIBTREE 码农题 线段树 树剖 标记永久化
好烦啊,调了半天 线段树部分标记比较多,手抖打错了一个 剩下的都是取模的问题 我自己瞎jb推的公式里保留了abs,但是在模意义下是gg的,所以必须把正负区分开 调试的时候一定要注意构造各种形状的树,不 ...
- criteria用法
Criteria Query通过面向对象化的设计,将数据查询条件封装为一个对象.简单来讲,Criteria Query可以看作是传统SQL的对象化表示,如: Java代码 Criteria cri ...
- NET高性能IO
System.IO.Pipelines: .NET高性能IO https://www.cnblogs.com/xxfy1/p/9290235.html System.IO.Pipelines是一个新的 ...
- 安装Jaspersoft Studio
下载位置:http://community.jaspersoft.com/project/jaspersoft-studio/releases.
- JAVA_HOME not recognized by tomcat7 in Ubuntu
vi .bashrc 添加: export JAVA_HOME=/usr/lib/jvm/java--oracle export JRE_HOME=$JAVA_HOME/jre export CLAS ...
- 仙人掌(cactus)
题目描述LYK 在冲刺清华集训(THUSC)!于是它开始研究仙人掌,它想来和你一起分享它最近研究的结果.如果在一个无向连通图中任意一条边至多属于一个简单环(简单环的定义为每个点至多经过一次),且不存 ...
- plsql连接远程数据库快捷方式
不用修改任何文件就可以直接连接远程数据库
- SpringBoot 2.x (15):Actuator监控
Actuator监控:SpringBoot自带的,对生成环境进行监控的系统 使用:既然是监控,那就不能监控一个空项目 这里我使用SpringBoot整合MyBatis的Demo: https://ww ...