Greedy Algorithm Problems in C/C++
The following is the list of C/C++ programs based on the level of difficulty:
Easy
- Activity Selection Problem | Greedy Algo-1
- Find Maximum Meetings in one Room
- Minimize the Sum of Product of Two Arrays with Permutations Allowed
- Maximise the Number of Toys that can be Purchased with Amount K
- Swap All Occurrences of Two Characters to Get Lexicographically Smallest String
- Find the Largest Number with Given Number of Digits and Sum of Digits
- Find the Minimum and Maximum Amount to Buy All N Candies
- Maximum Sum of Increasing Order Elements from N Arrays
- Huffman Coding | Greedy Algo-3
- Huffman Decoding
Medium
- Fractional Knapsack Problem
- Job Sequencing Problem
- How fo Find Shortest Paths from Source to All Vertices Using Dijkstra’s Algorithm
- Find Second Smallest Number from Sum of Digits and Number of Digits
- Graph Coloring | Set 2 (Greedy Algorithm)
- Prim’s Algorithm for Minimum Spanning Tree (MST)
- Minimum Steps to Empty String of ‘A’s and ‘B’s
- Number of Pairs in an Array with the Sum Greater Than 0
- Find Maximum Meetings in One Room
- Minimum Cost to Cut a Board into Squares
Hard
- Minimum Increment / Decrement to Make Array Elements Equal
- Minimum Number of Candies Required to Distribute among Children Based on Given Conditions
- Find Minimum Time to Finish All Jobs with Given Constraints
- Minimum Cost Path with Left, Right, Bottom and Up Moves Allowed
- Divide array into Increasing and Decreasing Subsequence without Changing the Order
- Find Smallest Range Containing Elements from K Lists
- Split the Given Array into K Sub-arrays Such That Maximum Sum af All Sub Arrays is Minimum
- Minimize Refills to Reach End of Path
- Rearrange a String so that All Same Characters Become D Distance Away
- Minimum Increment/Decrement to Make Array Non-increasing
- Dijkstra’s Algorithm for Adjacency List Representation | Greedy Algo-8
C/C++ Greedy Algorithms Programs
In greedy algorithms, the solution is constructed by choosing the current optimal solution without worrying about its effect in the future. The principle of greedy algorithms is that the local optimum may lead to the global optimum.
In this article, we will discuss some common Greedy algorithms practice problems in C/C++ language.
Prerequisite: Introduction to Greedy Algorithm