# Category Archives: Greedy

A Greedy Algorithm is defined as a problem-solving strategy that makes the locally optimal choice at each step of the algorithm, with the hope thatâ€¦ Read More
Given two integers N (N â‰¥ 1) and K (K â‰¥ 1), where N denotes the number of petrol pumps from 1 to N andâ€¦ Read More
Given a boolean array a[] of size N and integer K. Initially, all are marked false. We have to choose 2 different indexes having theâ€¦ Read More
Given an input array, the task is to convert the given array into an ‘even array’. An even array is an array where every numberâ€¦ Read More
Given an array X[] of length N, the task is to find the minimum number of times the operation is used to sort X[], ifâ€¦ Read More
Given two integers N and X. Then the task is to return YES or NO by checking whether there exists a subarray in any permutationâ€¦ Read More
Given a sorted array A[] of size N and an integer M. You need to divide the array A[] into M non-empty consecutive subarray (1â€¦ Read More
Given an array X[]. By using the given operation, you need to return the number of elements having the same initial value except 1 andâ€¦ Read More
Given a string S of length N. Select a Subsequence of character, delete it, and concatenate the remaining part of the String S. Let’s sayâ€¦ Read More
Given two matrices M1[][] and M2[][] of size R * C along with an integer X. In one operation select any cell of M1 let’sâ€¦ Read More
Given an array X[] of odd length N(N â‰¥ 3) and an integer K. Arrange elements of X[] in such a way that the mergedâ€¦ Read More
Given two positive integers N and K. Create a set of size N containing distinct positive integers such that the sum of no two integersâ€¦ Read More
Given an array nums[] of length N which contains integers, the task is to find a subarray such that the first and the last elementâ€¦ Read More
Given an array X[] of length N along with an integer K. Then the task is to choose a sub-sequence to maximize the sum byâ€¦ Read More
Given three points X, Y, and Z of a 2D plane, the task is to check if it is possible to move from X toâ€¦ Read More