贪心算法
crabstew
这个作者很懒,什么都没留下…
展开
-
[leetcode]贪心算法之jumpgame(一)(二)
贪心算法之jumpgame题干答案反思题干leetcode入口Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length a...原创 2019-04-21 21:39:25 · 294 阅读 · 0 评论 -
[leetcode]贪心算法之Monotone Increasing Digits
贪心算法之Monotone Increasing Digits题干答案反思题干Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits.(Recall that an integer has monotone i...原创 2019-04-21 22:46:43 · 151 阅读 · 0 评论 -
[leetcode]贪心算法之WiggleSubsequence
贪心算法之WiggleSubsequence题目思考代码题目leetcode入口思考而是维护两个变量p和q,然后遍历数组,如果当前数字比前一个数字大,则p=q+1,如果比前一个数字小,则q=p+1,最后取p和q中的较大值跟n比较,取较小的那个。p代表最后一个数字比前一个数字大的子序列的长度q代表最后一个数字比前一个数字小的子序列的长度代码class Solution {publi...原创 2019-05-14 12:11:25 · 121 阅读 · 0 评论