Skip to content

Category Archives: Greedy

Given an array arr[] of length N, the task is to find the largest sum contiguous subarray by adding an integer S exactly at K… Read More
Given a binary string S of length N. Distribute 0s and 1s of the string into K groups such that: Each group consists atleast a… Read More
Given a array vec and an integer K, count the number of pairs (i, j) such that vec[i]*vec[j] is divisible by K where i<j. Examples:… Read More
Given an array arr[] of length N, the task is to find the minimum number of replacements required to remove all peak elements of the… Read More
 Given two arrays arrA[] and arrB[] containing N integers each. Perform the following operation any number of times (possibly zero): Select any index i (0… Read More
Given two integers L and R, and an array arr[] containing single digit integers, the task is to find all the integers in the range… Read More
Given an array arr[] of size N. Find the minimum sum of the array after performing given operations any number of times: Select two different… Read More
Given an array arr[] consisting of N positive integers. In one operation any number of the array can be decremented by 1. The task is… Read More
Given two strings, S and T where S is a normal string and T is a compressed string, the task is to determine if the… Read More
Given an array A = [A0, A1, A2, . . ., AN-1]. Perform the following operation: Total count of indices with value same as their… Read More
Given an array arr[] and an integer L which represents the number of bits to be considered in bit representation of an array element. The… Read More
Given an array arr[] having N integers, the task is to find the maximum distance between any two occurrences of even integers. Examples: Input: arr[]… Read More
Given an N * M matrix mat[][] consisting of non-negative integers. In one operation, select any row and change all elements to 0. The task… Read More
Given a number N, the task is to represent N as sum of maximum number of unique positive integers. Examples:  Input: N = 12Output: 1+… Read More
Given a string str of length N, and an integer K, the task is to form K different strings by choosing characters from the given… Read More

Start Your Coding Journey Now!