# Category Archives: Greedy

Given an array arr[] of size N, the task is to find the minimum moves to segregate even and odd numbers by swapping two adjacent… Read More
Given an array A[] of size N, the task is to maximize the frequency of any element by adding any positive integer X to all… Read More
Given an array A[] of N integers, the task is to find the lexicographically smallest subsequence of the array by deleting all the occurrences of… Read More
Given an array arr[] of size N, the task is to find the minimum number of operations required to reduce all three elements of the… Read More
Given an array arr[] of length N and an integer M, the task is to determine if a strictly increasing sequence can be formed by… Read More
Given two integers M and N the task is to construct a binary palindromic string consisting of M occurrences of 0s and N occurrences of… Read More
Given two arrays of strings A[] and B[] containing only small case letters, the task is to count the number of strings in A[] such… Read More
Given an array of non-negative integers arr[] and an integer K, the task is to minimize the product of array elements by performing at K… Read More
Given a string S of size M consisting of only zeroes (and hence representing the integer 0). Also, given an array A[] of size N… Read More
Given an array arr[] of N integers such that no element is 0 in that array, the task is to find the minimum number of… Read More
Given an array A[] of N integers, the task is to find the number of pairs of indices (1 ≤ i, j ≤ N) in… Read More
Given a string S that consists of only alphanumeric characters and dashes. The string is separated into N + 1 groups by N dashes. Also… Read More
Given two arrays A[] and B[] of the same length N. the task is to find a pair (X, Y) for two numbers Ai (number… Read More
Given a string S consisting of lower case letters and an integer K, the task is to remove minimum number of letters from the string,… Read More
Given an array A[] of length N, the task is to minimize the maximum frequency of any array element by performing the following operation only… Read More