Skip to content

Category Archives: Greedy

Given a binary string, str, two integer arrays R[], and C[] of size N. Flipping all the characters from index i to R[i] requires C[i]… Read More
Given a string S of length N consisting of lowercase letters and an integer K, where N % K = 0, the task is to… Read More
Given an array arr[] consisting of N integers, the task is to find the mean of the array formed by the products of unordered pairs… Read More
Given an integer N, the task is to find the minimum positive product of first N – 1 natural numbers, i.e. [1, (N – 1)],… Read More
Given an array arr[] of size N, the task is to find the bitwise XOR of all possible unordered pairs of the given array.  Examples:… Read More
Given an integer N, split the first N natural numbers into two sets such that the absolute difference between their sum is minimum. The task… Read More
Given an array, arr[ ] of size N, the task is to rearrange the given array such that the product of all the elements of… Read More
Given a string S of length N containing lowercase alphabets. Two players A and B play a game optimally in turns, starting with player A.… Read More
Given an integer N, the task is to find the number of permutations of integers from the range [1, N] that can form an acyclic… Read More
Given an array arr[] consisting of N integers, the task is to count the total number of pairs of array elements from the given array… Read More
Given three integers X, Y, and N, the task is to find the minimum possible positive product of X and Y that can be obtained… Read More
Given an array arr[] of size N, the task is to count possible pairs of array elements (arr[i], arr[j]) such that (arr[i] + arr[j]) *… Read More
Given an array arr[] of size N, the task is for every array indices is to find the smallest missing non-negative integer upto that index… Read More
Given an array arr[] of size N, the task is to count all possible even length subarrays having bitwise XOR of subarray elements equal to… Read More
Given an integer N, the task is to find the number of ways N! can be split into two distinct factors A and B such… Read More