# Category Archives: Greedy

Given two integers N and E, where N represents the number of full water bottles and E represents the number of empty bottles that can… Read More
Given two integers N and X, the task is to find the count of all possible N digit numbers whose every single digit is a… Read More
Given an integer N, the task is to find the total number of right angled triangles that can be formed such that the length of… Read More
Given two integers N and M, the task is to find the vertex diagonally opposite to the Mth vertex of an N-sided polygon. Examples: Input:… Read More
Given a Binary Tree, the task is to find the length of the longest straight path of the given binary tree. Straight Path is defined… Read More
Given two numbers N and M which denotes the count of ones and zeros respectively, the task is to maximize the count of binary strings… Read More
Given string str of lowercase alphabets and an array cost[], where cost[i] represents the cost of deletion of ith character in the given string. The… Read More
Given string str consisting of lowercase alphabets, the task is to construct the lexicographically smallest non-palindromic string by swapping any pair of adjacent characters from… Read More
Given an integer N, the task is to print the number obtained by unsetting the least significant K bits from N. Examples: Input: N =… Read More
Given two integers L and R, the task is to count the numbers having only one unset bit in the range [L, R]. Examples: Input:… Read More
Given a binary string S of length N and an even integer K, the task is to check if all substrings of length K contains… Read More
Given a string S, the task is to find the sum of distances between all pairs of indices from the given string which contains the… Read More
Given an array arr[] consisting of N positive integers, the task is to find the minimum number of pairs (arr[i], arr[j]) from the given array… Read More
Given a positive integer N > 1, the task is to find the maximum GCD among all the pairs (i, j) such that i <… Read More
Given a tree with N vertices numbered from 0 to N – 1, M edges, and Q queries of the form {U, V}, such that… Read More