当前位置:网站首页>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---Warmups

Nacos配置文件管理、微服务获取Nacos配置文件
![[3D检测系列-PV-RCNN] PV-RCNN论文详解、PV-RCNN代码复现、包含官网PV-RCNN预训练权重及报错问题](/img/81/c929864440dc36238b3cb1deb9f112.png)
[3D检测系列-PV-RCNN] PV-RCNN论文详解、PV-RCNN代码复现、包含官网PV-RCNN预训练权重及报错问题

D - Project Planning--二分

idea2021.1.3配置Gradle步骤

软件测试人员必备的60个测试工具清单,建议收藏一波~

CAS:1192802-98-4_UV 裂解的生物素-PEG2-叠氮

AI首席架构师13-AICA-智能文档分析技术在行业场景中的应用

Use setTimeout to realize setInterval

MMA安装及使用优化
随机推荐
太香了! 阿里 Redis 速成笔记, 从头到尾全是精华!
卷起来!阿里高工携 18 位高级架构师耗时 57 天整合的 1658 页面试总结
XSS testing
基于支持向量机的网络⼊侵检测系统的全面调查和分类
聚焦开源与联合共创|麒麟软件出席开源峰会欧拉分论坛
XSS线上靶场---Warmups
C. awoo‘s Favorite Problem--Educational Codeforces Round 130 (Rated for Div. 2)
XSS online shooting range---haozi
从开发到软件测试:除了扎实的测试基础,还有哪些必须掌握 ?
461. 汉明距离
Orcad Capture Cadence 新建原理图多部分smybol和Homogeneous、Heterogeneous类型介绍教程
CAS:1260586-88-6_生物素-C5-叠氮_Biotin-C5-Azide
安全基础8 ---XSS
Markdown syntax
什么密码,永远无法被黑客攻破?
函数,递归以及dom简单操作
AWTK开发编译环境踩坑记录1(编译提示powershell.exe出错)
6. XML
LitJson报错记录
超级实用网站+公众号合集