Given an array A[] of size N and a positive integer K ( which will always be a factor of N), the task is to… Read More

# Category Archives: Greedy

Given an array arr[] of size N, the task is to check if it is possible to split the array arr[] into different subsequences of… Read More

Given an array arr[], the task is to find the minimum number increments or decrements by 1 required to convert the array into a Fibonacci… Read More

Given an array arr[] of size N, and an array Q[][] with each row representing a query of the form { X, Y }, the… Read More

Given a character array, str[] of consisting of N lowercase alphabets, and an integer array, arr[] consisting of numbers in the range [0, N –… Read More

Given two integers L and R, the task is to find the count of numbers in the range [L, R] whose first and last digit… Read More

Given two arrays S[] and E[] of size N denoting starting and closing time of the shops and an integer value K denoting the number… Read More

Given a binary string str, the task is to find the count of ways to partition the string such that each partitioned substring contains exactly… Read More

Given an array arr[] of size N, and an integer K, the task is to find the minimum count of pairs required to be removed… Read More

Given an integer N, the task is to find two integers with minimum possible sum such that their product is strictly greater than N. Examples:… Read More

Given two positive integers A and C, the task is to check if a number B exists such that A + B = C and… Read More

Given a numberic string N (1 ≤ |N| ≤ 105) and another numeric string S (1 ≤ |S| ≤ 105), the task is to find… Read More

Given an array Arr[] of N ( 1 ≤ N ≤ 105)integers, the task is to generate an array B[] consisting of N non-zero elements,… Read More

Given an array arr[] of size N, the task is to check if the array is spirally sorted or not. If found to be true,… Read More