Given an array arr[] consisting of N positive integers, the task is to find any permutation of given array such that the product of adjacent… Read More

# Category Archives: Greedy

Given an array arr[] of N integers, where N > 2, the task is to find the second largest product pair from the given array.… Read More

Given an array arr[] of N positive integers, the task is to find the minimum number of operations required of the following types to obtain… Read More

Given four integers N, M, X and Y, the task is to construct a N * M matrix such that each cell consists of a… Read More

Given an integer N (? 2), the task is to find the maximum GCD among all pairs possible by the integers in the range [1,… Read More

Given an N-ary Tree rooted at 1, and an array val[] consisting of weights assigned to every node, and a matrix Q[][], consisting of queries… Read More

Given a 2D matrix tsp[][], where each row has the array of distances from that indexed city to all the other cities and -1 denotes… Read More

Rearrange an Array such that Sum of same-indexed subsets differ from their Sum in the original Array

Given an array A[] consisting of N distinct integers, the task is to rearrange the given array such that the sum of every same-indexed non-empty… Read More

Given an array arr[] consisting of N integers, the task is to find the maximum count of decreasing subsequences possible from an array which satisfies… Read More

Given an array arr[] consisting of N integers, the task is to find the array K[] of minimum possible length such that after performing multiple… Read More

Given a palindromic string S, the task is to find the count of palindromic strings possible by swapping a pair of character at a time.Examples:… Read More

Given two arrays arr1[] and arr2[]. We can generate another array arr3[] by adding each element of the array arr1[] to each element arr2[]. The… Read More

Given two integers N and K, the task is to find the count of all possible N-digit numbers having sum of every K consecutive digits… Read More

Given a positive integer N, the task is to find the sum of the product of all the integers in the range [1, N] with their… Read More