Find an arrangement of M colors for N indices such that no two adjacent indices have same color and each color can be used at… Read More

# Category Archives: Greedy

Given a sentence S of size N where each word is a concatenation of a numeric part followed by a bunch of characters. The task… Read More

Given an array A[] of length N, the task is to find the minimum size of the array after selecting and removing distinct element pairs… Read More

Given an array arr[] of size N and an integer X, the task is to find the number of ordered pairs (i, j) such that… Read More

Given an array containing digits[], where each element is a single digit integer. The array may contain duplicates. The task is to find all the… Read More

Given an array arr[] of N positive integers, the task is to check whether an array can be made strictly increasing by shifting 1 value… Read More

Given an array arr[]. The task is to find the position of the leader element in arr[]. The leader element is the one, which can… Read More

Given a binary array arr[] of size N, and an integer K, the task is to check if K 0s can be flipped such that… Read More

Given arrays arr1[] of size M and arr2[] of size N having length at least 2, the task is for every element in arr1[], maximize… Read More

Given an array arr[] containing N integers. In each operation, a minimum integer is chosen from the array and deleted from the array after subtracting… Read More

Given a binary string S of size N, and a 2D array Q[][] of queries consisting of M pairs of the form {L, R}, the… Read More

Given a string str of N characters, the task is to find the lexicographically smallest string that can be formed by concatenating any prefix and… Read More

Given array arr containing N integers. the task is to find the maximum number of unique elements in the array if each element in the… Read More

Given an array arr[] and two integers L and R. The task is to find the sum of the product of all the pairs (i,… Read More