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】贪心算法与动态规划的区别与联系