Skip to content

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

Start Your Coding Journey Now!