Given two strings str1 and str2 of same length N, the task is to check if there exists any permutation possible in any of the… Read More

# Category Archives: Greedy

Given an array arr, the task is to find the maximum sum of subsequence after flipping signs of at most K elements. Examples: Input: arr… Read More

Given an integer array arr[] of N integers, the task is to make each adjacent pair in the array co prime, by adding minimum number of… Read More

Given an array A[] consisting of N intervals and a target interval X, the task is to find the minimum number of intervals from the… Read More

Given an array arr of N integers, the task is to calculate the length of longest sequence of consecutive integers that can be formed from… Read More

Given an array arr of N integers, and an array of keys, such that key for each element in arr is equal to its index… Read More

Given two positive integers X and K, the task is to find the K-th smallest positive integer Y, such that X + Y = X… Read More

Given an array arr of length N with values 1 and 2 indicating type 1 and type 2 elements and two players, player1 and player2.… Read More

Given a range [L, R], the task is to find the count of numbers in the range [L, R] that can be expressed as a… Read More

Given a positive integer N, the task is to find the maximum number of unique squares that can be formed with N arbitrary points in… Read More

Given a string S consisting of N lowercase alphabets, the task is to modify the given string by replacing all the characters with characters other… Read More

Given an undirected graph consisting of N valued over the range [1, N] such that vertices (i, i + 1) are connected and an array… Read More

Given a sorted array arr[] consisting of N positive integers, the task is to rearrange the array such that all the odd indices elements come… Read More

Given an integer K and an array arr[] having N pairwise distinct integers in the range [1, K], the task is to find the lexicographically… Read More