Category Archives: Greedy

Given an array arr[] of size N, the task is to find the smallest indexed array element whose sign needs to be flipped such that… Read More
Given an array arr[] of size N and an integer K (N % K = 0), the task is to split array into subarrays of… Read More
Given an array arr[] of even length N and an integer K, the task is to minimize the count of replacing array elements by an… Read More
Given an array arr[] consisting of N elements, the task is to find the minimum number of increments required to be performed on the given… Read More
Given a string S of length N, the task is to check if a string can be split into two substrings, say A and B… Read More
Given an array arr[] of positive integers of size N, the task is to check if there exists two non-intersecting subarrays in arr[] such that… Read More
Given three integers L, R, and K, the task is to find the maximum sum of K even multiples of 5 from the range [L,… Read More
Given an integer N (N &e; 3), the task is to split all numbers from 1 to N into two subsequences such that the sum… Read More
Given two numeric strings N and K (K ≤ N), where digits of K are in non-decreasing order, the task is to rearrange digits of… Read More
Given two arrays arr1[] and arr2[] of size N, the task is to count the minimum number of swaps of same-indexed elements from both the… Read More
Given an integer N denoting the number of flights and array bookings[][3] with each row of the form {a, b, K} denoting that there are… Read More
Given an integer N, the task is to find the Bitwise XOR of all odd numbers in the range [1, N]. Examples: Input: 11Output: 2Explanation:… Read More
Given an integer N, the task is to find the smallest number greater than or equal to N such that it is divisible by all… Read More
Given an integer N, the task is to find the path from the Nth node to the root of a Binary Tree of the following… Read More
Given a sorted array arr[] consisting of N distinct elements, the task is to find the maximum possible common difference of an arithmetic progression such… Read More