# Category Archives: Greedy

Given binary string str, the task is to find the minimum number of characters required to be flipped to make all 1s in right and… Read More
Given an array A[] of size N, the task is to find the maximum length of the longest non-decreasing array that can be generated from… Read More
Given binary string str, and integers A, which denotes the cost of converting consecutive 1s to 0s, and B, which denotes the cost of converting… Read More
Given an array arr[] consisting of N integers and an array Q[][], where each row is a query of the form {L, R}. The task… Read More
Given an array arr[] having N distinct positive elements, the task is to generate another array B[] such that, for every ith index in the… Read More
Given an array arr[] containing a permutation of first N natural numbers. In one operation, remove a pair (X, Y) from the array and insert… Read More
Given an integer N, the task is to find all non-negative pairs (A, B) such that the sum of Bitwise OR and Bitwise AND of… Read More
Given an array arr[] consisting of N integers and an array Q[][], where each row denotes a range {l, r}(0 ≤ l ≤ r ≤… Read More
Given an array arr[] consisting of N integers, the task is to find the maximum index K such that the product of subarrays {arr, arr[K]}… Read More
Given integers N, K, A, and B, check if it is possible to reach B from A in a circular queue of integers from 1… Read More
Given integer N and integer S, the task is to find the smallest number greater than or equal to N such that the sum of… Read More
Given an array arr[] of size N, having an equal number of even and odd integers, the task is to find the minimum number of… Read More
Given a 2D array arr[][], where each row is of the form {start, end} representing the start and endpoints of each line segment on the… Read More
Given an integer N, the task is to count the number of pairs of prime numbers in the range [1, N] such that the difference… Read More
Given an array arr[], the task is to find the length of the longest subsequence of the array arr[] such that all adjacent elements in… Read More