# Category Archives: Greedy

## Closest pair in an Array such that one number is multiple of the other

Given an array arr[] of integers of size N, the task is to find the closest pair in the given array such that one element… Read More »

## Count of bitonic substrings from the given string

Given a string str, the task is to count all the bitonic substrings of the given string. A bitonic substring is a substring of the… Read More »

## Minimum LCM of all subarrays of length at least 2

Given an array arr[] of N positive integers. The task is to find the minimum LCM of all subarrays of size greater than 1. Examples: … Read More »

## Count substring of Binary string such that each character belongs to a palindrome of size greater than 1

Given a binary string str, the task is to count the number of substrings of the given string str such that each character of the… Read More »

## Minimum integer with at most K bits set such that their bitwise AND with N is maximum

Given an integer N which can be represented in 32 bit, the task is to find another integer X that has at most K bits… Read More »

## Minimum minutes needed to make the time palindromic

Given a string str which stores the time in the 24 hours fomat as “HH:MM”. The task is to find the minimum minutes needs to… Read More »

## Convert string to integer without using any in-built functions

Given a string str, the task is to convert the given string into the number without using any inbuilt function. Examples:  Input: str = “985632”… Read More »

## Permutation of Array such that sum of adjacent elements are not divisible by 3

Given an array arr[] of positive integers, the task is to find the permutation of the array such that sum of adjacent elements is not… Read More »

## Maximum sum of values in a given range of an Array for Q queries when shuffling is allowed

Given an array arr[] and K subarrays in the form (Li, Ri), the task is to find the maximum possible value of . It is… Read More »

## Count of unique digits in a given number N

Given a number N, the task is to count the number of unique digits in the given number. Examples: Input: N = 22342 Output: 2 Explanation:The digits… Read More »

## Maximum profit such that total stolen value is less than K to get bonus

Given an integer K and an array arr[] which denotes the amount that can be stolen, the task is to choose a subset of items… Read More »

## Length of longest subsequence in an Array having all elements as Nude Numbers

Given an array arr[] of N positive integers, the task is to print the length of the longest subsequence of the array such that all… Read More »

## Largest subset having with sum less than equal to sum of respective indices

Given an array arr[], the task is to find the length of the largest subset with the sum of elements less than or equal to… Read More »

## Count of unique palindromic strings of length X from given string

Given a string s and an integer X, our task is to find the number of distinct palindromic strings of length X from the given… Read More »

## Maximum possible Array sum after performing given operations

Given array arr[] of positive integers, an integer Q, and arrays X[] and Y[] of size Q. For each element in arrays X[] and Y[],… Read More »