Given a string S consisting of N lowercase English alphabets, and an integer K and, an array cost[] of size 26 denoting the cost of… Read More

# Category Archives: Greedy

Given two arrays A[] and B[] consisting of N integers, the task is to find the maximum number of 0s in the array A[] that… Read More

Given an array arr[] of size N, the task is to count the number of non-empty subsets whose product is equal to P1×P2×P3×……..×Pk where P1,… Read More

Given a square matrix arr[][] of size N consisting of non-negative integers and an integer K, the task is to find the maximum median value… Read More

Given a sorted array arr[] consisting of N positive integers such that arr[i] represent the days in which a worker will work and an array… Read More

Given an array arr[] of N strings such that each string consists of characters ‘(‘ and ‘)’, the task is to find the maximum number… Read More

Given a sorted array arr[] consisting of N integers, and an integer K, the task is to find the minimum number of elements to be… Read More

Given two integers A and B, the task is to find the minimum number of moves needed to make A equal to B by incrementing… Read More

Given a matrix arr[][] of dimension M*N consisting of positive integers, where arr[i][j] represents the height of each unit cell, the task is to find… Read More

Given a sac of capacity W, and two arrays A[] and B[] of length N, where A[i] represents the weight of an ith block of… Read More

Given an array, arr[] of N integers, the task is to find the maximum possible count of adjacent pairs with an even sum, rearranging the… Read More

Given string S and a positive integer K, the task is to find lexicographically the largest possible string using at most K swaps with the… Read More

There are many ways of classifying algorithms and a few of them are shown below: Implementation Method Design Method Other Classifications Classification by Implementation Method:… Read More

Given two positive integers N and K, the task is to print the minimum count of numbers needed to get the sum equal to K,… Read More

Given two strings S and T, the task is to merge these two strings by adding one character at a time from the beginning of… Read More