LeetCode常见题型——贪心算法

1. 算法思想

保证每次操作都是局部最优的,从而使最后得到的结果是全局最优的。

2. 相关例题

LeetCode-455. Assign Cookies [C++][Java]_贫道绝缘子的博客-CSDN博客Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.https://blog.csdn.net/qq_15711195/article/details/122953498

LeetCode-135. Candy [C++][Java]_贫道绝缘子的博客-CSDN博客Returnthe minimum number of candies you need to have to distribute the candies to the children.https://blog.csdn.net/qq_15711195/article/details/122953774

LeetCode-435. Non-overlapping Intervals [C++][Java]_贫道绝缘子的博客-CSDN博客Given an array of intervalsintervalswhereintervals[i] = [starti, endi], returnthe minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.https://blog.csdn.net/qq_15711195/article/details/122902742

LeetCode-605. Can Place Flowers [C++][Java]_贫道绝缘子的博客-CSDN博客Given an integer arrayflowerbedcontaining0's and1's, where0means empty and1means not empty, and an integern, returnifnnew flowers can be planted in theflowerbedwithout violating the no-adjacent-flowers rule.https://blog.csdn.net/qq_15711195/article/details/122972969

LeetCode-452. Minimum Number of Arrows to Burst Balloons [C++][Java]_贫道绝缘子的博客-CSDN博客Given the arraypoints, returntheminimumnumber of arrows that must be shot to burst all balloons.https://blog.csdn.net/qq_15711195/article/details/122973165

LeetCode-763. Partition Labels [C++][Java]_贫道绝缘子的博客-CSDN博客You are given a strings. We want to partition the string into as many parts as possible so that each letter appears in at most one part.https://blog.csdn.net/qq_15711195/article/details/122973579

LeetCode-122. Best Time to Buy and Sell Stock II [C++][Java]_贫道绝缘子的博客-CSDN博客On each day, you may decide to buy and/or sell the stock. You can only holdat most oneshare of the stock at any time. However, you can buy it then immediately sell it on thesame day. Find and returnthemaximumprofit you can achieve.https://blog.csdn.net/qq_15711195/article/details/122993359

LeetCode-121. Best Time to Buy and Sell Stock [C++][Java]_贫道绝缘子的博客-CSDN博客You want to maximize your profit by choosing asingle dayto buy one stock and choosing adifferent day in the futureto sell that stock. Returnthe maximum profit you can achieve from this transaction. If you cannot achieve any profit, return0.https://blog.csdn.net/qq_15711195/article/details/122993511

LeetCode-123. Best Time to Buy and Sell Stock III [C++][Java]_贫道绝缘子的博客-CSDN博客Find the maximum profit you can achieve. You may completeat most two transactions. Note:You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).https://blog.csdn.net/qq_15711195/article/details/122993610

LeetCode-406. Queue Reconstruction by Height [C++][Java]_贫道绝缘子的博客-CSDN博客You are given an array of people,people, which are the attributes of some people in a queue (not necessarily in order). Eachpeople[i] = [hi, ki]represents theithperson of heighthiwithexactlykiother people in front who have a height greater than ohttps://blog.csdn.net/qq_15711195/article/details/122896232

LeetCode-665. Non-decreasing Array [C++][Java]_贫道绝缘子的博客-CSDN博客Given an arraynumswithnintegers, your task is to check if it could become non-decreasing by modifyingat most one element.https://blog.csdn.net/qq_15711195/article/details/122994121

参考文献

【1】搜索、贪心和动态规划的区别 

【2】贪心算法与动态规划的区别与联系 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贫道绝缘子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值