# Category Archives: Greedy

## Number of ways to sum up a total of N from limited denominations

Given a number N and two arrays arr1[] and arr2[] of length 4. The array arr1[] denotes the denomination of 1, 5, 10, and 20… Read More »

## Check if all array elements can be removed by the given operations

Given an array arr[] containing distinct elements, the task is to check if all array elements can be removed by the selecting any two adjacent… Read More »

## Count of subarrays which forms a permutation from given Array elements

Given an array A[] consisting of integers [1, N], the task is to count the total number of subarrays of all possible lengths x (1… Read More »

## Minimum flips required to convert given string into concatenation of equal substrings of length K

Given a binary string S and an integer K, the task is to find the minimum number of flips required to convert the given string… Read More »

## Smallest N digit number divisible by all possible prime digits

Given an integer N, the task is to find the smallest N digit number divisible by all possible prime digits, i.e, 2, 3, 5 and… Read More »

## Minimum cost to empty Array where cost of removing an element is 2^(removed_count) * arr[i]

Given an array arr[], the task is to find the minimum cost to remove all elements from the array where cost of removing an element… Read More »

## C++ Program for the Fractional Knapsack Problem

Pre-requisite: Fractional Knapsack Problem Given two arrays weight[] and profit[] the weights and profit of N items, we need to put these items in a… Read More »

## Minimum number of distinct powers of 2 required to express a given binary number

Given a binary string S, the task is to find the minimum number of Powers of 2 required to express a S.Examples:   Input: S =… Read More »

## Split a Numeric String into Fibonacci Sequence

Given a numeric string S representing a large number, the task is to form a Fibonacci Sequence of at least length 3 from the given… Read More »

## Smallest subarray whose product leaves remainder K when divided by size of the array

Given an array arr[] of N integers and an inetger K, the task is to find the length of the smallest subarray whose product when… Read More »

## Smallest subarray having an element with frequency greater than that of other elements

Given an array arr of positive integers, the task is to find the smallest length subarray of length more than 1 having an element occurring… Read More »

## Count of array elements whose order of deletion precedes order of insertion

Given an initial array, A[] and a final array B[] both of size N containing integers from the range [1, N], where A[] represent the… Read More »

## Count of Missing Numbers in a sorted array

Given a sorted array arr[], the task is to calculate the number of missing numbers between the first and last element of the sorted array.… Read More »

## Construct a matrix with sum equal to the sum of diagonal elements

Given an integer N, the task is to construct a matrix of size N2 using positive and negative integers and excluding 0, such that the… Read More »

## 3 Different ways to print Fibonacci series in Java

Given a number N, we need to find the Fibonacci Series up to the N term. The Fibonacci series is a series of elements where,… Read More »