# Category Archives: Greedy

Given an integer N and a base X, the task is to find the minimum number of operations required to represent N as a sum… Read More
Given Q queries in array A[] of three types of the form {type, X} and an empty array B[], the task for this problem is… Read More
Given a string s and an integer k, the task is to remove k characters from the string such that the sum of ASCII values… Read More
Given array A[], the task for this problem is to check whether A[] can be formed from array B[] = {1} by performing the following… Read More
Given an array X[] and a matrix M[][]. Then the task is to output the minimum elements needed to remove so that one row and… Read More
Given an array arr[] of N positive integers (> 0). The task is to check if it is possible to make all array elements equal… Read More
Given a string str consisting of only two characters ‘a‘ and ‘b‘, the task is to find the minimum steps required to make the string… Read More
Given an array arr[] having n integers, divide the array into two halves, such that all elements in the array’s second half are unique elements.… Read More
Given an array X[] of length N, Where X[i] for (1 ≤ i ≤ N) denotes the number of rupees we need to give to… Read More
Given a binary array X[] of size N. Two players A and B are playing games having the following rules, then the task is to… Read More
Given an array arr[] of positive and negative integers. If two adjacent elements have different signs, remove them. Find the final array if the operation… Read More
Given an array A[] and the operation of swapping two elements if their sum is even, find a resulting array B[] such that all prefix… Read More
Given an input array arr[], convert a given array to an ‘odd array’ consisting of only odd numbers. An even number can be made odd… Read More
Given two arrays arr1[] of length N and arr2[] of length N – 1 and is built such that arr2[i] = max(arr1[i], arr1[i+1]) for all 1… Read More
Given three positive integers X, Y, Z. Find  (X0+X1+X2+X3+X4+…………………..+Xy-1) % Z. Examples: Input: X = 4, Y = 5, Z = 6Output: 5Explanation: 40+41+42+43+44 =… Read More