Skip to content

Category Archives: Greedy

Given a string S representing the time in the 24-hour format “HH:MM” such that some digits are represented by ‘?’, the task is to replace… Read More
Patience sorting is a sorting algorithm based on card game Patience. In this sorting algorithm the rules of patience game is used to sort an… Read More
Given an array arr[] consisting of N positive integers and a positive integer K, the task is to find the minimum number of elements that… Read More
Given two numbers A and B, the task is to find the maximum Greatest Common Divisors(GCD) that can be obtained by adding a number X… Read More
Given an array arr[] consisting of N positive integers, the task is to check if each array element can be represented in terms of numbers… Read More
Given an undirected connected graph of N nodes and M edges. Each node has a light but at a time it can be either green… Read More
Given an array arr[] of size N, the task is to print the minimum number of moves needed to make all array elements equal by… Read More
Given two arrays L[] and R[] of size N, and an integer K, the task is to find the number of ways to select exact… Read More
Given an array of pairs ranges[] of size M and an integer N, the task is to find a binary string of length N such… Read More
Given an array arr[][] consisting of N pairs such that each pair {L, R} represents that ith house can be painted in L number of… Read More
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
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