Skip to content

Category Archives: Greedy

Given a range [L, R], the task is to find all possible co-prime pairs from the range such that an element doesn’t appear in more… Read More
Given 3 integers K, P and N. Where, K is the number of problems given to the person every day and P is the maximum… Read More
Given a string str, the task is to check if it can be rearranged to get a special palindromic string. If we can make it… Read More
Given a string S having N directions in which a person travels. The task is to check if he/she will be able to return to… Read More
Given a string S containing only Uppercase letters, the task is to find the minimum number of replacement of characters needed to get a string… Read More
Given a string which consists of either ‘.’ or any number. A ‘.’ in the string means that the cell is empty and if there… Read More
Given a number N, the task is to find the number of pairs containing an even and an odd number from numbers between 1 and… Read More
Given an array of size N, the task is to determine whether its possible to sort the array or not by just one shuffle. In… Read More
Given a list of items and their values. The task is to find top k items with the highest value. It is possible that two… Read More
Given a number N. The task is to check if the digits of the number follow any of the below order:   The digits are in… Read More
Given a function, Y = (X^6 + X^2 + 9894845) % 971 for a given value. The task is to find the value of the… Read More
Given an array of N positive integers. The task is to check if the array is sorted in wave form.Examples:   Input: arr[] = {1, 2,… Read More
Given N works numbered from 1 to N. Given two arrays, D1[] and D2[] of N elements each. Also, each work number W(i) is assigned… Read More
Given a string consisting only of two lowercase characters and and two numbers and . The task is to print the lexicographically smallest permutation of the given string such… Read More
Consider a two player coin game where each player gets turn one by one. There is a row of even number of coins, and a… Read More