# Category Archives: Greedy

## Minimum number of changes such that elements are first Negative and then Positive

Given an array arr[] of size N. The task is to find the minimum number of changes required to convert the array such that for… Read More »

## Sum of elements in an array whose difference with the mean of another array is less than k

Given two unsorted arrays arr1[] and arr2[]. Find the sum of elements from arr1[] whose difference with the mean of arr2[] is < k. Examples:… Read More »

## Find n positive integers that satisfy the given equations

Given three integers N, X and Y. The task is to find N positive integers that satisfy the given equations. a12 + a22 + ….… Read More »

## Find the minimum number of steps to reach M from N

Given two integers N and M. The task is to find the minimum number of steps to reach M from N by performing given operations.… Read More »

## Find the number of jumps to reach X in the number line from zero

Given an integers X. The task is to find the number of jumps to reach a point X in the number line starting from zero.… Read More »

## Maximum number of candies that can be bought

Given an array arr[] of size n where arr[i] is the amount of candies of type i. You have unlimited amount of money. The task… Read More »

## Maximum array sum that can be obtained after exactly k changes

Given an array arr[] of n integers and an integer k. The task is to maximize the sum of the array after performing the given… Read More »

## Spanning Tree With Maximum Degree (Using Kruskal’s Algorithm)

Given an undirected unweighted connected graph consisting of n vertices and m edges. The task is to find any spanning tree of this graph such… Read More »

## Maximal Disjoint Intervals

Given a set of N intervals, the task is to find the maximal set of mutually disjoint intervals. Two intervals [i, j] & [k, l]… Read More »

## Given count of digits 1, 2, 3, 4, find the maximum sum possible

Given the count of digits 1, 2, 3, 4. Using these digits you are allowed to only form numbers 234 and 12. The task is… Read More »

## Replace all elements by difference of sums of positive and negative numbers after that element

Given an array of positive and negative elements. The task is to replace every i-th element of the array by the absolute difference of absolute… Read More »

## Optimal File Merge Patterns

Given n number of sorted files, the task is to find the minimum computations done to reach Optimal Merge Pattern. When two or more sorted… Read More »

## Maximize the value of the given expression

Given three non-zero integers a, b and c. The task is to find the maximum value possible by putting addition and multiplication signs between them… Read More »

## Minimum cuts required to convert a palindromic string to a different palindromic string

Given palindromic string s, the task is to find minimum k, such that you can cut this string into k+1 parts, and then unite them… Read More »

## Minimum changes required such that the string satisfies the given condition

Given a binary string str. In a single operation, we can change any ‘1’ to ‘0’ or any ‘0’ to ‘1’. The task is to… Read More »