Skip to content

# Category Archives: Greedy

Given an array arr[] consisting of N positive integers and an integer K, the task is to find the highest frequency of any array element… Read More
Given two positive integers X and Y, the task is to check if it is possible to convert the number X into Y, either by… Read More
Given a positive integer N, the task is to count all numbers which are less than N and Bitwise AND of all such numbers with… Read More
Given an array A[] of size N, the task is to find the minimum sum of numbers required to be added to array elements to… Read More
Given two arrays arr1[] and arr2[] consisting of N and M integers respectively, the task is to find the probability of randomly selecting the two… Read More
Given an array arr[] consisting of N integers, the task is to find the maximum Bitwise XOR of Bitwise OR of every subarray after splitting… Read More
Given an array arr[] of size N, the task is to assign points to every distinct array element such that the sum of the points… Read More
Given a string S of length N, consisting of lowercase alphabets, the task is to find the lexicographically longest string that can be obtained by… Read More
Given a binary string, S of size N, the task is to check if it is possible to partition the string into disjoint subsequences equal… Read More
Given an array arr[] consisting of N positive integers representing the ratings of N children, the task is to find the minimum number of candies… Read More
Given an array A[] consisting of N integers(1-based indexing), the task is to find the minimum value of the function  for any possible value of X.… Read More
Given a 2D array arr[][] of size N*M consisting of ‘.’ and ‘*’ characters representing a floor and two positive integers A and B representing… Read More
Given two strings A and B of size N and M respectively, the task is to count characters of the string A, which when removed… Read More
Given two binary strings A and B of length N, the task is to convert the string A to B by either flipping any character… Read More
Given an array arr[] of size N, the task is to find the minimum sum of absolute differences of an array element with all elements… Read More