# 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