# Category Archives: Greedy

Given an array arr[] of size N, the task is to calculate the maximum sum that can be obtained by dividing the array into several… Read More
Given an array arr[ ] of size N, consider an array prefix[ ] where prefix[i] is the sum of the first i elements of arr.… Read More
Given a binary string S of size N, the task is to find the maximum number of operations that can be performed on S, by… Read More
Given a positive integer K and a string S consisting of N characters, the task is to maximize the sum of the frequencies of exactly… Read More
Introduction of the Hu-Tucker algorithm :The Hu-Tucker algorithm helps to compress some order of blocks, assuming that you have a certain natural order for the… Read More
Given a positive integer N, the task is to count the number of N-digit numbers having absolute difference between consecutive digits in non-increasing order. Examples:… Read More
Given an array arr[] consisting of N integers and an integer K, the task is to find the maximum sum of K pairs of the… Read More
Given three numbers N, K, and M, the task is to find the maximum value that can be assigned to the Kth index if positive… Read More
Given a positive integer K and two arrays A[] and B[] of size N and M respectively, each containing elements in the range [1, K].… Read More
Given a string S, the task is to find the string which is lexicographically smallest and not a subsequence of the given string S.  Examples:… Read More
Given an array of pairs Edges[][], representing edges connecting vertices in a Tree consisting of N nodes, the task is to find the minimum time… Read More
Given four integers N, M, A, and B, the task is to print all numbers ( in increasing order ) that can be obtained by… Read More
Given an array arr[] of N non-zero integers, the task is to find the maximum sum of the array by removing exactly one contiguous set… Read More
Given an array arr[] of size N, representing the diameter of N circular buildings and a straight wire of length L. The task is to… Read More
Given an array arr[] of N candies, with N being an even number and arr[i] representing the type of candy. The task is to find… Read More