Skip to content

Category Archives: Greedy

Given a matrix of dimension N*N whose all cells are initially 0. You are given Q queries, each of type {a, b, c, d} where… Read More
Given a string S of length N, the task is to find two non-intersecting strings of equal length such that the sum of absolute differences… Read More
Given a string S of size N consisting of characters from ‘0’to ‘9’, the task is to minimize the length of the string where In… Read More
Greedy algorithm, divide and conquer algorithm, and dynamic programming algorithm are three common algorithmic paradigms used to solve problems. Here’s a comparison among these algorithms:… Read More
Given a string S consisting of only lowercase characters, the task is to find the lexicographically smallest string after removing exactly K characters from the… Read More
Greedy algorithm and divide and conquer algorithm are two common algorithmic paradigms used to solve problems. The main difference between them lies in their approach… Read More
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

Start Your Coding Journey Now!