Skip to content

Category Archives: Greedy

Given an array arr[] of size N consisting only of 0s and 1s, the task is to find the minimum number of operations required to… Read More
Given an undirected graph with N nodes (numbered from 0 to N-1) such that any node can be reached from any other node and there… Read More
Given a string S of length N, the task is to find the minimum number of moves required to make a string palindrome where in… Read More
Find the count of numbers between L and R and are coprime with P. Note: Two numbers X and Y are coprime with each other… Read More
Construct a matrix whose each row contains N 1’s and each column contains M 1’s. Examples: Input: N = 3, M = 4Output:1 1 11… Read More
Given two arrays X[] and Y[] of length N each. You can shift from X[] to Y[] at most once. The task is to output… Read More
Given two strings A and B which are permutations of each other. The task is to find the minimum number of rotations required to delete… Read More
Given an arr[] of length N. Then the task is to find minimum steps to make all the elements of the given array equal. Two… Read More
Given an array arr[] consisting of N non-negative integers. The task is to find a rearrangement of the array such that the prefix OR for… Read More
Given an array arr[] of size N and you need to fill another empty array of size N with positive integers. Each element in the… Read More
Given an integer N (N ≥ 5) Then assume you have two infinite arrays X and Y where X[] is an array of element N… Read More
Given an array A[] of size N. In one operation only one subarray can be selected and replaced with the sum of the subarray. The… Read More
Given N points moving along the X axis to the right whose initial position and speed are given in two arrays X[] (sorted in increasing… Read More
Given integer N, the task is to print an upside-down triangle where the left half is made of elements in the range [1, N*(N+1)/2] and… Read More
Given a list of words followed by two words, the task is to find the minimum distance between the given two words in the list… Read More

Start Your Coding Journey Now!