Given a list of N distinct integers and a list of N-1 inequality signs, the task is to insert the integers between the inequality signs,… Read More

# Category Archives: Greedy

Given a sorted array arr[] of N distinct positive integers. The task is to generate an array such that the element at each index in… Read More

Given an integer N, the task is to print all the possible ways in which N can be written as the sum of two or… Read More

Given an array of items, an ith index element denotes the item id’s, and given a number m, the task is to remove m elements… Read More

Given non-negative integers K, M, and an array arr[] with N elements find the Mth element of the array after K left rotations. Examples: Input:… Read More

Given a matrix mat[][], pair of indices X and Y, the task is to find the number of moves to bring all the non-zero elements… Read More

Given a string str, the task is to check whether the given string is linear or not. If it is linear then print “Yes” else… Read More

Given an Undirected Graph consisting of N vertices and M edges, where node values are in the range [1, N], and vertices specified by the… Read More

Given a Binary Tree, the task is to find the maximum value of GCD from any path from the root node to the leaf node.… Read More

Given a string str, the task is to check if string str is a substring of an infinite length string S in which lowercase alphabets… Read More

Given an array arr[], the task is to rearrange the array to generate maximum decreasing subsequences and print the count of the maximum number of… Read More

Given four integers N, X, P, and Q, the task is to find the minimum cost to make N to 1 by the following two… Read More

Given an integer N and two arrays increasing[] and decreasing[], such that they have elements from 1 to N only. The task is to find… Read More

Given a number N and two arrays arr1[] and arr2[] of length 4. The array arr1[] denotes the denomination of 1, 5, 10, and 20… Read More