Skip to content

Category Archives: Greedy

Given a list of names in an array arr[] of size N, display the longest name contained in it. If there are multiple longest names… Read More
Given three integers N, K and D, the task is to construct an array of size N such that every subarray of size K has… Read More
Given a 2D array arr of size N which represents an interval [start, end] inclusive where (start < end), the task is to add only… Read More
Given two strings S1 and S2 of the same length containing characters ranging from ‘0’ to ‘9’, the task is to return the minimum number… Read More
Given a binary string consisting of ‘0’ and ‘1’ only and an integer K, the task is to minimize the string as far as possible… Read More
Given an array B[] of length N, the task is to print an array A[] such that for every ith element B[i] is gcd of… Read More
Given an array A[] of size N where each element A[i] =max(P[0], P[1], . . ., P[i]), where P[] is a permutation consisting of elements… Read More
Given positive integers N, A, B and C such that 1 ≤ C < N. The task is to maximize the value of B by… Read More
Given a string S of size N consisting of characters ‘0’ to ‘9’, the task is to print the longest palindrome that can be formed… Read More
Given a binary string S of length N and an integer X, the task is to check if there exists a right-wise circular rotation of… Read More
Given a permutation A[] of first N integers (i.e. array contains integers from 1 to N exactly once) and an integer K, the task is… Read More
Given an array Arr[] of size N, the cost of removing ith element is Arr[i]. The task is to remove the maximum number of elements… Read More
Given an array A, the task is to find elements with the occurrence at least K times the frequency of the least occurring element in… Read More
Given a string S consisting of only lowercase English letters of length N, the task is to find the count of substrings such that each… Read More
Given a number N, the task is to find the minimum number X such that A(X) = N, where A(X) for positive integer X is… Read More

Start Your Coding Journey Now!