# Category Archives: Algorithms

Given an integer N and an array arr[] of M pairs of type (Ai, Bi), the task is to generate the lexicographically smallest possible permutation… Read More
Dynamic programming (DP) is arguably the most important tool in a competitive programmer’s repertoire. There are several optimizations in DP that reduce the time complexity… Read More
Given an array arr[] of size N, the task is to calculate the minimum number of elements to be removed from the array such that… Read More
Given an integer array having N elements ranging from 1 to N and each element appearing exactly once. The task is to find the number… Read More
Given an array arr of length N of distinct numbers and an integer X, the task is to find the minimum number of elements that… Read More
Given an array arr[] of size N and three integers X, Y and K, the task is to count the number of pairs (i, j)… Read More
Given a string S of size N containing lowercase English letters, representing a phone number(all phone numbers will be 10 digits) in words, the task… Read More
Instance simplification is one of the Transform and Conquer techniques. To understand Instance Simplification, first let us understand what is transform and conquer. Transform and… Read More
Knuth’s optimization is a very powerful tool in dynamic programming, that can be used to reduce the time complexity of the solutions primarily from O(N3)… Read More
Given three arrays A[], B[] and C[] of size N each and two integers X and Y, the task is to, find the minimum cost… Read More
Given a string S of length N consisting of digits and an integer K, Reduce the string by performing the following operation till the length… Read More
Given an array arr[] of positive integers of size N, the task is to divide the array into two non-empty subsets X and Y in… Read More
Given a grid on the XY plane with dimensions r x c (where r denotes maximum cells along the X axis and c denotes maximum… Read More
Given an array arr[] of size N, the task is to find if there exists a pair in the array, such that their bitwise XOR… Read More
Given an array arr[] of length N, the task is to count the number of pairs (i, j) such that arr[i] * arr[j] > 0… Read More