# Category Archives: Greedy

## Largest number made up of X and Y with count of X divisible by Y and of Y by X

Given three integers X, Y and N, the task is to find the largest number possible of length N consisting only of X and Y… Read More »

## Minimum count of numbers required with unit digit X that sums up to N

Given two integers N and X, the task is to find the minimum count of integers with sum N and having unit digit X. If… Read More »

## Maximum bitwise OR value of subsequence of length K

Given an array arr[] of N positive integers and a number K, the task is to find the maximum value of bitwise OR of the… Read More »

## Maximum cost path in an Undirected Graph such that no edge is visited twice in a row

Given an undirected graph having N vertices and M edges and each vertex is associated with a cost and a source vertex S is given.… Read More »

## Reverse a subarray of the given array to minimize the sum of elements at even position

Given an array arr[] of positive integers. The task is to reverse a subarray to minimize the sum of elements at even places and print… Read More »

## Minimize sum of smallest elements from K subsequences of length L

Given an array arr[] of size N, the task is to find the minimum possible sum by extracting the smallest element from any K subsequences… Read More »

## Smallest number to be added in first Array modulo M to make frequencies of both Arrays equal

Given two arrays A[] and B[] consisting of N positive integers and a integer M, the task is to find the minimum value of X… Read More »

## Count all indices of cyclic regular parenthesis

Given a string S of length N, consisting of only opening ‘(‘ and closing ‘)‘ parenthesis. The task is to find all indices ‘K‘ such… Read More »

## Count of 0s to be flipped to make any two adjacent 1s at least K 0s apart

Given a binary string s and a number K, the task is to find the maximum number of 0s that can be replaced by 1s… Read More »

## Lexicographically smallest string after M operations

Given a string S and integer M. The task is to perform exactly M operations to get lexicographical smallest string. In each operation, select one… Read More »

## Maximum number of bridges in a path of a given graph

Given an undirected graph, the task is to count the maximum number of Bridges between any two vertices of the given graph. Examples: Input: Graph… Read More »

## Maximize jobs that can be completed under given constraint

Given an integer N denoting number of jobs and a matrix ranges[] consisting of a range [start day, end day] for each job within which… Read More »

## Count of ways to split given string into two non-empty palindromes

Given a string S, the task is to find the number of ways to split the given string S into two non-empty palindromic strings. Examples:… Read More »

## Minimum number of points required to cover all blocks of a 2-D grid

Given two integers N and M. The task is to find the minimum number of points required to cover an N * M grid. A… Read More »

## Minimize number of boxes by putting small box inside bigger one

Given an array size[] of box sizes, our task is to find the number of boxes left at the end, after putting the smaller sized… Read More »