Greedy Algorithms Last Updated : 25 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Greedy algorithms are a class of algorithms that make locally optimal choices at each step with the hope of finding a global optimum solution. At every step of the algorithm, we make a choice that looks the best at the moment. To make the choice, we sometimes sort the array so that we can always get the next optimal choice quickly. We sometimes also use a priority queue to get the next optimal item.After making a choice, we check for constraints (if there are any) and keep picking until we find the solution.Greedy algorithms do not always give the best solution. For example, in coin change and 0/1 knapsack problems, we get the best solution using Dynamic Programming.Examples of popular algorithms where Greedy gives the best solution are Fractional Knapsack, Dijkstra's algorithm, Kruskal's algorithm, Huffman coding and Prim's AlgorithmBasics of Greedy AlgorithmIntroduction to Greedy Algorithm Greedy Algorithms General StructureEasy Problems on Greedy AlgorithmFractional KnapsackMin Cost to Make Array Size 1Min Rotations for Circular LockMax Composite Numbers to Make nSmallest Subset Greater SumAssign CookiesBuy Maximum Stocks Max Consecutive Diff SumMin and Max Costs to buy allMin Notes with Given SumMax Equal Sum of Three StacksMedium Problems on Greedy AlgorithmActivity Selection ProblemJump Game Job Sequencing ProblemEgyptian FractionMerge Overlapping IntervalsMin Fibonacci Terms with Sum KMinimum PlatformsMin Cost to Connect n ropes Max trains Partition 1 to n into two min diff groupsPaper cut into min squaresMin diff groups of size twoMax Satisfied Customers Min initial vertices to traverse matrix with constraintsLargest palindromic number by permuting digitsSmallest with n digits and digits sumLexicographically largest subsequence with every char at least k timesHard Problems on Greedy AlgorithmMinimize the Max Height DiffMaking max equal with k updatesMinimize cash flow among friendsMinimum Cost to cut a board into squaresMinimum cost to process m tasks where switching costsMinimum time to finish all jobs with given constraintsMinimize the maximum difference between the heights of towersMinimum edges to reverse to make path from a source to a destinationFind the Largest Cube formed by Deleting minimum Digits from a numberRearrange characters in a string such that no two adjacent are sameRearrange a string so that all same characters become d distance awayStandard Greedy AlgorithmsActivity Selection ProblemJob Sequencing ProblemHuffman CodingHuffman DecodingWater Connection ProblemMinimum Swaps for Bracket BalancingEgyptian FractionPolicemen catch thievesFitting Shelves ProblemAssign Mice to HolesGreedy Problems on ArrayMinimum product subset of an arrayMaximize array sum after K negations using SortingMinimum sum of product of two arraysMinimum sum of absolute difference of pairs of two arraysMinimum increment/decrement to make array non-IncreasingSorting array with reverse around middleSum of Areas of Rectangles possible for an arrayLargest lexicographic array with at-most K consecutive swapsPartition into two subarrays of lengths k and (N – k) such that the difference of sums is maximumGreedy Problems in Operating SystemFirst Fit algorithm in Memory ManagementBest Fit algorithm in Memory ManagementWorst Fit algorithm in Memory ManagementShortest Job First SchedulingJob Scheduling with two jobs allowed at a timeProgram for Optimal Page Replacement AlgorithmGreedy Problems on GraphKruskal’s Minimum Spanning TreePrim’s Minimum Spanning TreeBoruvka’s Minimum Spanning TreeDijkastra’s Shortest Path AlgorithmDial’s AlgorithmMinimum cost to connect all citiesMax Flow Problem IntroductionNumber of single cycle components in an undirected graphApproximate Greedy Algorithm for NP CompleteSet cover problemBin Packing ProblemGraph ColoringK-centers problemShortest superstring problemApproximate solution for Travelling Salesman Problem using MSTGreedy for Special cases of DPFractional Knapsack ProblemMinimum number of coins requiredQuick LinksLearn Data Structure and Algorithms | DSA TutorialTop 20 Greedy Algorithms Interview Questions‘Practice Problems’ on Greedy Algorithms‘Quiz’ on Greedy Algorithms Greedy Algorithms Visit Course Comment More infoAdvertise with us H harendrakumar123 Follow Improve Article Tags : Greedy DSA Algorithms-Greedy Algorithms Practice Tags : Greedy Explore Basics & PrerequisitesLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 2 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 4 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 14 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 6 min read Problem of The Day - Develop the Habit of Coding 5 min read Like