
greedy
老晨磕技术
每天定时定量,持之以恒。一天一点数十年持续积累,坚持的人总不会混得太差。
展开
-
晨哥Leetcode 1040. Moving Stones Until Consecutive II
https://leetcode.com/problems/moving-stones-until-consecutive-ii/Example 1:Input: [7,4,9]Output: [1,2]Explanation:We can move 4 -> 8 for one move to finish the game.Or, we can move 9 -> 5...原创 2019-09-03 07:03:14 · 596 阅读 · 0 评论 -
老晨Leetcode 376. Wiggle Subsequence 摆动序列
如果连续数字之间的差严格地在正和负之间交替,则这样的数字序列称为摆动序列。 第一个差值(如果存在)可以是正的也可以是负的。 少于两个元素的序列通常是摆动序列。例如,[1,7,4,9,2,5]是一个摆动序列,因为连续数字的差(6,-3,5,-7,3)交替为正和负。 相反,[1,4,7,2,5]和[1,7,4,5,5]不是摆动序列,第一个是因为它的前两个连续数字的差是正的,而第二个是因为它的最后一...原创 2019-09-16 10:28:02 · 125 阅读 · 0 评论 -
老晨Leetcode 659 分割数组为连续子序列 · Split Array into Consecutive Subsequences
给定一个整数数组 nums. 现在需要将 nums 拆分成若干个 (至少1个) 子序列, 并且每个子序列至少包含 3 个连续的整数.返回是否能做到这样的拆分.Example 2:Input: [1,2,3,3,4,4,5,5]Output: TrueExplanation:You can split them into two consecutive subsequences :...原创 2019-09-19 23:57:54 · 436 阅读 · 0 评论