Skip to content

Category Archives: Greedy

Given a triplet of integers (A, B, C), the task is to count the maximum number of decrements by 1 that can be performed on… Read More
Given an integer N, the task is to count the number of distinct prime triplets (a, b, c) from the range [1, N] such that… Read More
Given integers N, L and W representing number of rows and length and width of houses in each row, and an array Heights[], representing the… Read More
Given an array A[] consisting of N integers, the task is to count the number of pairs (i, j) such that i < j, and… Read More
Given two arrays A[] and B[] consisting of N integers representing the amount of each type of candies and maximum consumable limit respectively, and an… Read More
Given two arrays row[] and col[] of size N and M respectively, the task is to construct a matrix of dimensions N * M such… Read More
Given an array arr[] consisting of N integers representing N rods each with a disk of radius arr[i], the task is to check if it… Read More
Given two strings A and B of length N and M respectively and an array arr[] consisting of K integers, the task is to check… Read More
Given an array arr[] of size N and a positive integer X, the task is to the partition the array into maximum number of subsets… Read More
Given a binary string S of length N, the task is to find the minimum number of characters required to be inserted such that all… Read More
Given two strings A and B, the task is to count the minimum number of operations required to construct the string B by following operations:  … Read More
Given two binary arrays arr1[] and arr2[] of the same size, the task is to make both the arrays equal by swapping pairs of arr1[… Read More
Given an array arr[] consisting of N integers which are either 0 or 7, the task is to find the largest number that can be… Read More
Given two positive integers N and K, the task is to generate an array consisting of N distinct integers such that the sum of elements… Read More
Given an array arr[] of size N, the task is to find the maximum sum possible of the count of distinct prime factors of K… Read More