Skip to content

Category Archives: Greedy

Given an array arr[] and an integer K. The task is to find the size of the maximum sub-set such that every pair from the… Read More
Given a string of consecutive digits and a number Y, the task is to find the number of minimum sets such that every set follows… Read More
Given an array A[] of size N / 2, the task is to construct the array B[] of size N such that: B[] is sorted… Read More
Given an integer X > 1 and an integer K > 0, the task is to find the greatest odd number < X such that… Read More
Given two integers L and R, the task is to find the greatest divisor that divides all the natural numbers in the range [L, R].Examples:  … Read More
Given an array of 2 * n elements, the task is to construct and print an array of n element such that the mean of… Read More
Given an array consisting of N positive integer numbers. The task is to remove exactly one element from this array to minimize max(a) – min(a)… Read More
You have an unlimited number of 10-rupee coins and exactly one coin of r rupee and you need to buy minimum items each of cost… Read More
Given an array arr[] of size n ≥ 3, the task is to find the minimum possible difference between the maximum and the minimum element… Read More
Given an array of integers. The task is to find the minimum number of consecutive sequences that can be formed using the elements of the… Read More
Given a string str and an integer array width[] where: width[0] = width of character ‘a’ width[1] = width of character ‘b’ … width[25] =… Read More
Given two arrays of size N and two integers X and Y indicating the maximum number of elements one can pick from array A and… Read More
Given an array arr of N (even) integer elements. The task is to check if it is possible to reorder the elements of the array… Read More
Given an array of integers arr[], the task is to count the number of valid pairs of elements from arr. A pair (arr[x], arr[y]) is… Read More
Given an array of integers. The task is to find the maximum sum of all the elements of the array after performing the given two… Read More