# Category Archives: Competitive Programming

## Minimum digits to remove to make a number Perfect Square

Given a integer n, we need to find how many digits remove from the number to make it a perfect square. Examples : Input :… Read More »

## Dynamic Disjoint Set Data Structure for large range values

Prerequisites: Disjoint Set Data Structure Set Unordered_Map Disjoint Set data structure is used to keeps track of a set of elements partitioned into a number… Read More »

## Inclusion Exclusion principle and programming applications

Sum Rule – If a task can be done in one of ways or one of ways, where none of the set of ways is… Read More »

## Minimum total cost incurred to reach the last station

Given an array where each element denotes the number of chocolates corresponding to each station and to move from station i to station i+1, we… Read More »

## Find if neat arrangement of cups and shelves can be made

Given three different types of cups (a[]) and saucers (b[]), and n number of shelves, find if neat arrangement of cups and shelves can be… Read More »

## Possible timings

Given a one/two digit timing, calculate the possibilities of occurrence of other timings(including the glowing one) with relevant to glowing segments, assuming some segments may… Read More »

## Water Connection Problem

Every house in the colony has at most one pipe going into it and at most one pipe going out of it. Tanks and taps… Read More »

## Number of terms in Geometric Series with given conditions

A geometric progression is a sequence of integers b1, b2, b3, …, where for each i > 1, the respective term satisfies the condition bi… Read More »

## Check if it is possible to convert one string into another with given constraints

Given two strings contains three characters i.e ‘A’, ‘B ‘and ‘#’ only. Check is it possible to convert first string into another string by performing… Read More »

## Smallest number with sum of digits as N and divisible by 10^N

Find the smallest number such that the sum of its digits is N and it is divisible by . Examples : Input : N =… Read More »

## Sum of f(a[i], a[j]) over all pairs in an array of n integers

Given an array of n integers, find the sum of f(a[i], a[j]) of all pairs (i, j) such that (1 <= i < j <=… Read More »

## Number of horizontal or vertical line segments to connect 3 points

Given three points on the x-y coordinate plane. You need to find the no. of line segments formed by making a polyline passing through these… Read More »

## Remove the forbidden strings

Given a string W, change the string in such a way that it does not contain any of the “forbidden” strings S1 to Sn as… Read More »

## Maximum number of customers that can be satisfied with given quantity

A new variety of rice has been brought in supermarket and being available for the first time, the quantity of this rice is limited. Each… Read More »