# Category Archives: Greedy

Given a string S of length N consisting of lowercase alphabets, the task is to count the minimum number of characters that need to be… Read More
Given a 2D array houses[][] consisting of N 2D coordinates {x, y} where each coordinate represents the location of each house, the task is to… Read More
Given a binary string S of length N, the task is to find the minimum number of removal of adjacent similar characters required to empty… Read More
Given an array, arr[] of size N, the task is to count the number of unordered pairs such that Bitwise AND and Bitwise OR of… Read More
Given a matrix M[][] of dimensions N * M, the task is to find the minimum number of increments of matrix elements by 1 required… Read More
Given a regular polygon of N sides, the task is to find the maximum sided polygon that can be inscribed inside the given polygon by… Read More
Given a binary string, str and a 2D array Q[][] representing queries of the form {L, R}. In each query, toggle all the characters of… Read More
Given an integer N, the task is to reduce N to 1 by a minimum number of operations involving multiplication by 2 and division by… Read More
Given an integer N, the task is to check if there exists any permutation of the first N natural numbers [1, N] such that Bitwise… Read More
Given an array, arr[] of size N and an integer K, the task is to find the minimum number of operations required to make all… Read More
Given two arrays A[] and B[] consisting of N integers (N is odd), the task is to rearrange array B[] such that for each 1… Read More
Given two arrays A[] and B[] consisting of N integers, the task is to update array A[] by assigning every array element A[i] to a… Read More
Given an array arr[] of size N, the task is to find the number of subarrays having sum of its elements equal to the number… Read More
Given a string S of length N, consisting of only lowercase English characters, the task is to find the minimum number of adjacent swaps required… Read More
Given an array arr[] consisting of N characters, the task is to generate a graph of N nodes and (N – 1) Edges such that… Read More