Greedy

Greedy is one kind of algorithmic paradigm that follows the approach of making the locally optimal choice at each stage that leads to the globally optimum solution. A greedy algorithm always takes the best immediate or local solution while finding the final solution. Any problem having optimal substructure and greedy property can be solved using a greedy algorithm.

Basic Greedy Problems

To solve any basic greedy problem, identify an optimal subproblem or substructure in the problem and solve the subproblems in an optimal way. Create some sort of iterative way to go through all of the subproblems and find the global optimum solution. Any problem having optimal substructure and greedy property can be solved using a greedy algorithm. The greedy method is quite powerful and works well for a wide range of problems such as Activity selection problem, Job scheduling problem, Fractional Knapsack problem, etc.

Minimum count of Inversion Pairs possible by concatenating N binary strings in any order

By HET FADIA

● Published At Jan 2022

The blog aims to find the minimum count of Inversion Pairs possible by concatenating N binary strings in any order.... Keep reading ..

Minimum Count of Inversion Pairs Possible by Concatenating N Binary Strings in any Order

By Ujjawal Gupta

● Published At Jan 2022

In this blog, we will learn to solve a problem based on sorting. We will discuss the problem minimum count of inversion pairs possible by concatenating ‘N’ binary strings in any order.... Keep reading ..

Finding Kth Largest Number in a Given Array of Large Numbers

By Ujjawal Gupta

● Published At Jan 2022

In this blog, we will learn to solve a problem based on sorting. We will discuss the approach based on the overloading of the comparator function.... Keep reading ..

Count Strings that Do Not Contain Any Alphabet’s Both Uppercase and Lowercase

By Ishita Chawla

● Published At Dec 2021

This blog will discuss the problem to count strings that do not contain any alphabet’s both uppercase and lowercase.
... Keep reading ..

Find the smallest range containing at least 1 element from given N ranges.

By Urwashi Priya

● Published At Dec 2021

This article will brief you on how to Find the smallest range containing at least 1 element from given N ranges.
... Keep reading ..

Minimum Decrements to Make an Array at Most Zero Such That All Array Elements Are Cyclically Decremented After a Number is Reduced to Zero

By Ujjawal Gupta

● Published At Jan 2022

In this blog, we will learn to solve a problem, minimum decrements to make an array at most zero such that all array elements are cyclically decremented after a number is reduced to zero.... Keep reading ..

Lexicographically Incrementing or Decrementing Characters to Convert Characters of STRING1 to Characters Present in STRING2

By Sujal Modanwal

● Published At Jan 2022

The task is to find the minimum operations to convert the characters of string1 to the character present in string2.... Keep reading ..

Sum of beauty in the array

By Sandeep kamila

● Published At Jan 2022

This article discusses the different approaches to finding the sum of beauty in the array with examples and its implementation in C++.... Keep reading ..

Optimization Problems

The optimization problem is the problem of finding the best solution from all feasible solutions. To solve these problems constraints must be known. This involves finding of maximum and minimum values of some function. It is an important tool in making decisions and analyzing physical systems.

Minimize the sum of minimum and second minimum elements from all possible triplets

By Sandeep kamila

● Published At Dec 2021

This article covers the approach to minimize the sum of minimum and second minimum elements from all possible triplets with its C++ code.... Keep reading ..

Minimize the Sum of Minimum and Second Minimum Elements from All Possible Triplets

By Saksham Gupta

● Published At Feb 2022

In this blog, we will discuss a classical problem of the greedy Algorithm and a famous interview question, i.e., minimize the sum of minimum and second minimum elements from all possible triplets.
... Keep reading ..

Minimize Cost for Reducing Array by Replacing Two Elements with Sum at most K times for any Index

By Aman Chourasiya

● Published At Dec 2021

In this blog, we will discuss a problem based on n-ary trees and prefix sums. We will transform and visualise a problem in a graphical way to draw certain conclusions.... Keep reading ..

Minimize Deletions from Either End to Remove Minimum and Maximum from Array

By Sujal Modanwal

● Published At Jan 2022

The task is to find the minimum number of deletions from start or end to remove minimum and maximum elements of the array.
... Keep reading ..

Maximize cost obtained by removal of substrings “pr” or “rp” from a given String

By Aditya Narayan Joardar

● Published At Nov 2021

This article discusses maximizing the by removing the substring "pr" or "rp" from a given string.... Keep reading ..

Minimize insertions or deletions to make the frequency of each array element equal to its value

By Aman Chourasiya

● Published At Dec 2021

This blog discusses a coding challenge based on greedy algorithms. Greedy algorithms are one of the most asked topics in technical interviews and programming contests.... Keep reading ..

Maximize score by rearranging Array such that absolute difference of first and last element is minimum

By Aman kumar Chourasiya

● Published At Jan 2022

In this blog, we will discuss a coding challenge that involves the use of sorting and greedy algorithms. Greedy algorithms are well known for their simplicity and ease to understand.... Keep reading ..

Minimize Swaps to Make Remainder Equal When an Element and its Index is Divided by K

By Sujal Modanwal

● Published At Jan 2022

The task is to find minimum swaps required to make every element’s remainder with k equal to its index remainder with k.... Keep reading ..

Maximize the frequency of an element by at most one increment or decrement of all array elements

By Sandeep kamila

● Published At Dec 2021

This article covers the approach to maximize the frequency of an element by at most one increment or decrement of all array elements with complete explanation and its C++ code.... Keep reading ..

Minimize Flips to Make the Binary String as all 1s by Flipping Characters in a Substring of size K Repeatedly

By Aman kumar Chourasiya

● Published At Jan 2022

In this blog, we will take up a coding problem based on strings. We will learn to use a greedy approach to solve the challenge.... Keep reading ..

Maximum Ice Cream Bars

By Sandeep kamila

● Published At Mar 2022

This blog will cover the approach of the Maximum Ice Cream Bars problem with its C++ code.... Keep reading ..

## Top Problems related to Greedy

Connect N Ropes With Minimum Cost

Minimum operation needed to convert to the given string

Minimum Number of Platform Needed

Minimum Number of Platforms

Rearrange The Array

Minimum Number Of Lamps

Minimum Number Of Taps To Water Garden

Next Permutation

Jump Game

Candies

Compress the String

Overlapping ABBA

Add One to Linked List

Dijkstra's shortest path

Normal BST To Balanced BST

Shortest Path

Connect Ropes

Minimum days to complete work

Job Scheduling Problem

Fact Digit Sum

Count Number Of Ways To Cover A Distance