Lec 4
Lec 4
Adv.
● Easier to describe and code up .
● Often be implemented more efficiently than other algorithms.
Drawbacks-
● Designing greedy algorithms can be easy,finding the right approach can be hard.
● Showing a greedy algorithm is correct often requires a nuanced argument.
Greedy Problems
https://leetcode.com/problems/stone-game/description/
https://codeforces.com/problemset/problem/276/C
https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/description/
https://www.geeksforgeeks.org/optimal-strategy-for-a-game-dp-31/
Fractional Knapsack
Q. Given weights and values of N items, we need to put these items in a knapsack of
capacity W to get the maximum total value in the knapsack.
Note: you are allowed to break the item.
Algo:-
Problems
https://www.geeksforgeeks.org/problems/n-meetings-in-one-room-1587115620/1
https://leetcode.com/problems/merge-intervals/description/
https://leetcode.com/problems/maximum-earnings-from-taxi/description/