Given an array Q[] of length N, the task is to find the permutation P[] of integers from the range [1, N + 1] such… Read More
Tag Archives: Constructive Algorithms
Given an M x N matrix mat[][]. The task is to count the number of good cells in the matrix. A cell will be good… Read More
Given two integers A and B. The task is to find the count of all possible values X such that A % X = B.… Read More
Given an array arr[] of positive integers, the task is to find whether it is possible to make this array strictly increasing by modifying atmost… Read More
Given a matrix mat[][], the task is to check if the given matrix is strictly increasing or not. A matrix is said to be strictly… Read More
Given a string str, the task is to check whether the given string is made up of only two alternating characters.Examples: Input: str = “ABABABAB” Output:… Read More
Given two integer N and K, the task is to find the sum of all the numbers from the range [1, N] excluding those which… Read More
Given an array arr[] of non-negative integers. We have to delete elements from this array such that arr[i + 1] > arr[j] for each valid… Read More
There are infinite people standing in a row, indexed from 1. A person having index i has strength of i2. You have strength P and… Read More
Given an integer array arr[] of size N and an integer K, the task is to find the index which will be the last to… Read More
Given an array arr[] of N distinct integers, the task is to find the maximum element in an interval [L, R] such that the interval… Read More
Given an array of digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array.… Read More
Given an equilateral triangle made of dots (.) joined together to form triangle and an integer n which represents the length of the sides of… Read More
Given two integers N and Y, the task is to generate a sequence of N distinct non-negative integers whose bitwise-XOR of all the elements of… Read More
Given an array arr[] of 1’s and 2’s, the task is to re-arrange the array in such a way that the prefix sum of the… Read More