Skip to content

Category Archives: Greedy

Given an array arr[], find the lexicographically largest array that can be obtained by performing at-most k consecutive swaps.  Examples :  Input : arr[] =… Read More
There are n servers. Each server i is currently processing a(i) amount of requests. There is another array b in which b(i) represents the number… Read More
Given a number k, find the required minimum number of Fibonacci terms whose sum equal to k. We can choose a Fibonacci number multiple times.… Read More
You are given an array of n-elements, you have to find the number of operations needed to make all elements of array equal. Where a… Read More
You are a poor person in an island. There is only one shop in this island, this shop is open on all days of the… Read More
Given n arrays of size m each. Find the maximum sum obtained by selecting a number from each array such that the elements selected from… Read More
There are n cities and there are roads in between some of the cities. Somehow all the roads are damaged simultaneously. We have to repair… Read More
Huffman Encoding is an important topic from GATE point of view and different types of questions are asked from this topic. Before understanding this article,… Read More
Minimum spanning Tree (MST) is an important topic for GATE. Therefore, we will discuss how to solve different types of questions based on MST. Before… Read More
There are n students in a class, each in possession of a different funny story. As the students were getting bored in the class, they… Read More
Every house in the colony has at most one pipe going into it and at most one pipe going out of it. Tanks and taps… Read More
Find the smallest number such that the sum of its digits is N and it is divisible by .Examples :   Input : N = 5 Output… Read More
Given a positive integer n such that n > 2. Divide numbers from 1 to n in two groups such that absolute difference of sum… Read More
Given a string S, change the smallest number of letters in S such that all adjacent characters are different. Print the resultant string.Examples :   Input… Read More
A new variety of rice has been brought in supermarket and being available for the first time, the quantity of this rice is limited. Each… Read More