# Category Archives: Greedy

Given two arrays X[] and Y[] of length N each. You can make a pair by selecting exactly one element from X[] and Y[]. The… Read More
Given a binary string S and a string of non-zero digits P of length N, the task is to maximize the sum using the given… Read More
Given an undirected graph of N node, where nodes are numbered from 1 to N, and an array of edges, where edges[i] = {edgeType, u,… Read More
You are given a binary string S of size N consisting of characters 0 and/or 1. You may remove several characters from the beginning or… Read More
Given an array A[] of size N. In each step reduce an element to 0 and decrement all the non-zero elements by 1 till all… Read More
Given a binary array A[] of size N, the task is to check whether the array can be converted into a palindrome by flipping two… Read More
Given two binary arrays A[] and B[] of size N, the task is to construct the lexicographically smallest binary array X[]  such that the number… Read More
Given a matrix mat[][] of size M x N where mat[i][j], the task is to find the maximum possible sum by picking contiguous elements from… Read More
Given an array arr[] of N distinct non-negative integers, the task is to determine if there is an even number that can be represented as… Read More
Consider two arrays arr1[] and arr2[] each of size N such that arr1[] contains all odd numbers between 1 to 2*N and arr2[] contains all… Read More
Given a matrix of size N * M. Every cell of the matrix contains either ‘A’ or ‘B’. Exchange is defined as swapping the characters… Read More
Given an array arr[] of length N. You can perform at most K operations on the array of the following type:  Choose an index i… Read More
Given an integer arr[] of length N such that (Ai > 0) for all (1 ≤ i ≤ N) and an integer X. In one… Read More
Given two numbers N and K, and a pair A and B, the task is to multiply N by A or B as many times… Read More
Given an array stream of n integers in the form of a stream, the task is to find the minimum number of operations that are… Read More