当前位置:网站首页>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?
边栏推荐
猜你喜欢
尚医通项目总结
XSS online shooting range---haozi
LitJson报错记录
461. 汉明距离
2022年全国职业院校技能大赛网络安全 B模块 任务十windows操作系统渗透测试 国赛原题
【kali-漏洞扫描】(2.1)Nessus解除IP限制、扫描快无结果、插件plugins被删除(中)
nxp官方uboot移植到野火开发板PRO(修改LCD部分和网络部分)
[kali-vulnerability scanning] (2.1) Nessus download and installation (on)
肝完 Alibaba 这份面试通关宝典,我成功拿下今年第 15 个 Offer
ValidationError: Progress Plugin Invalid Options
随机推荐
关于GPIO你真的懂了吗?这篇文章都给你整理好了
tidyverse based on data.table?
详解虚拟机!京东大佬出品 HotSpot VM 源码剖析笔记(附完整源码)
ES6--residual parameters
尚医通项目总结
dataframe multi-level index replace index df.swaplevel(axis=1)
STP生成树
基于data.table的tidyverse?
【历史上的今天】8 月 3 日:微软研究院的创始人诞生;陌陌正式上线;苹果发布 Newton OS
函数,递归以及dom简单操作
『百日百题 · 基础篇』备战面试,坚持刷题 第四话——循环语句!
一体化HTAP数据库如此难,为什么他们还要做?
检测和控制影子IT的五个步骤
有趣的opencv-记录图片二值化和相似度实现
IO线程进程->线程同步互斥机制->day6
461. 汉明距离
CAS:122567-66-2_DSPE-生物素_DSPE-Biotin
A. Color the Picture- Codeforces Round #810 (Div. 1)
YOLO之父宣布退出CV界,坦言无法忽视自己工作带来的负面影响
CAS:1192802-98-4_UV 裂解的生物素-PEG2-叠氮