Skip to content

Category Archives: Greedy

Given a string S consisting of N alphabets and two positive integers L and U, representing the cost of converting any character to lowercase and… Read More
Given three non-negative integers A, B, and C, the task is to count the numbers in the range [1, C] that can be reduced to… Read More
Given an array arr[] consisting of N integers, the task is to find the last remaining array element after removing every second element, starting from… Read More
Given a string S of length N, consisting of lowercase characters containing reordered English representations of digits [0 – 9], the task is to print… Read More
Given a positive integer N, the task is to count the number of integers from the range [1, N], that can be represented as ab,… Read More
Given an array weight[] consisting of weights of N items and a positive integer C representing the capacity of each bin, the task is to… Read More
Given an array arr[] consisting of N positive integers and a 2D array Q[][] consisting of queries of the type {i, val}, the task for… Read More
Given two integers X and Y representing the number of candies allocated to players A and B respectively, where both the players indulge in a… Read More
Given two integers N and C, representing the number of boys and candies, and an integer K, the task is to calculate the maximum and… Read More
Given two integers S and M, the task is to find the coefficients of the quadratic equation such that the sum and the product of… Read More
Given an array arr[] consisting of N integers, the task is to find the length of the smallest subarray required to be removed to make… Read More
Given a string S consisting of N lowercase alphabets, the task is to check if it is possible to split the string S into three… Read More
Given two positive integers N and K, the task is to count the number of triplets (a, b, c) such that 0 < a, b,… Read More
Given a binary array arr[] of size N, the task is to find the total cost required to make all array elements equal to 1,… Read More
Given a string S of length N consisting only of characters ‘a’, ‘b’, and ‘c’, the task is to minimize the length of the given… Read More