当前位置:网站首页>376. Wiggle Subsequence
376. Wiggle Subsequence
2022-08-03 21:29:00 【51CTO】
A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.
For example, [1,7,4,9,2,5] is a wiggle sequence because the differences (6,-3,5,-7,3) are alternately positive and negative. In contrast, [1,4,7,2,5] and [1,7,4,5,5] are not wiggle sequences, the first because its first two differences are positive and the second because its last difference is zero.
Given a sequence of integers, return the length of the longest subsequence that is a wiggle sequence. A subsequence is obtained by deleting some number of elements (eventually, also zero) from the original sequence, leaving the remaining elements in their original order.
Examples:
Follow up:
Can you do it in O(n) time?
边栏推荐
- 肝完 Alibaba 这份面试通关宝典,我成功拿下今年第 15 个 Offer
- 好朋友离职了,一周面试了20多场,我直呼内行
- CAS:1260586-88-6_生物素-C5-叠氮_Biotin-C5-Azide
- CAS:153162-70-0_N-BOC-6-生物素酰氨基己胺
- YOLO之父宣布退出CV界,坦言无法忽视自己工作带来的负面影响
- 有趣的opencv-记录图片二值化和相似度实现
- 现网设备兼容SRv6网络演进
- 【kali-漏洞扫描】(2.1)Nessus下载安装(上)
- 如何使用 Jmeter获取登录token并设置为全局变量?
- 解决npm -v查看npm版本出现npm WARN config global `--global`, `--local` are deprecated. Use `--location报错
猜你喜欢
Linux操作Jmeter(附带:关于连接上redis无法进行写入操作的问题),JMeter配置多用户进行压力测试
tidyverse based on data.table?
【kali-漏洞利用】(3.2)Metasploit基础(上):基础知识
[kali-vulnerability scanning] (2.1) Nessus download and installation (on)
《强化学习周刊》第56期:GraphIRL、REDEEMER & 眼科强化学习的潜在研究
XSS practice - cycle and two cycle problem at a time
CC2530_ZigBee+华为云IOT:设计一套属于自己的冷链采集系统
shell编程基础
CAS: 1192802-98-4 _uv cracking of biotin - PEG2 - azide
Five Steps to Detect and Control Shadow IT
随机推荐
Security Fundamentals 8 --- XSS
[kali-vulnerability exploitation] (3.2) Metasploit basics (on): basic knowledge
从0到1看支付
如何基于WPF写一款数据库文档管理工具(二)
C. Array Elimination-- Codeforces Round #751 (Div. 2)
主板设计中:网络变压器与RJ45网口之间应该保持什么样的距离?
这几个常用 alias,带你高效做事(下)
小朋友学C语言(1):Hello World
检测和控制影子IT的五个步骤
dataframe 多层索引 更换索引 df.swaplevel(axis=1)
超级实用网站+公众号合集
电商数仓ODS层-----日志数据装载
尚医通项目总结
分分钟教你读取 resources 目录下的文件路径
IDaaS 是什么?一文说清它的价值
2022年全国职业院校技能大赛网络安全 B模块 任务十windows操作系统渗透测试 国赛原题
StoneDB 助力 2022 开放原子全球开源峰会
ES6--residual parameters
LitJson报错记录
三年黑盒测试工程师对嵌入式软件测试的理解