## Check if it is possible to reach a number by making jumps of two given length

Given a starting position ‘k’ and two jump sizes ‘d1’ and ‘d2’, our task is to find the minimum number of jumps needed to reach… Read More »

## Find array using different XORs of elements in groups of size 4

Given an array q[] of XOR queries of size N (N is a multiple of 4) which describe an array of the same size as… Read More »

## Rectangle with minimum possible difference between the length and the width

Given an integer area, the task is to find the length and breadth of a rectangle with the given area such that the difference between… Read More »

## Some useful C++ tricks for beginners in Competitive Programming

Here are some of the basic C++ tricks that every beginner in Competitive Programming should follow for increased speed. However, competitive programming can only be… Read More »

## Minimize the number of replacements to get a string with same number of ‘a’, ‘b’ and ‘c’ in it

Given a string consisting of only three possible characters ‘a’, ‘b’ or ‘c’. The task is to replace characters of the given string with ‘a’,… Read More »

## Shortest Path using Meet In The Middle

Given a permutation P = p1, p2, …., pn of first n natural numbers (1 ≤ n ≤ 10). One can swap any two consecutive… Read More »

## Check if it is possible to get back to 12’0 clock only by adding or subtracting given seconds

Given N seconds. The task is to check if it is possible to start from 12’0 clock and get back to 12 only adding or… Read More »

## Median Of Running Stream of Numbers – (using Set)

Given that integers are being read from a data stream. Find the median of all the elements read so far starting from the first integer… Read More »

## Largest subset where absolute difference of any two element is a power of 2

Given an array arr[] of distinct elements -109 ≤ ai ≤ 109. The task is to find the largest sub-set from the given array such… Read More »

## Count of strings that become equal to one of the two strings after one removal

Given two strings str1 and str2, the task is to count all the valid strings. An example of a valid string is given below: If… Read More »

## Printing pre and post visited times in DFS of a graph

Depth First Search (DFS) marks all the vertices of a graph as visited. So for making DFS useful, some additional information can also be stored.… Read More »

## Maximum of all Subarrays of size k using set in C++ STL

Given an array of size N and an integer K, the task is to find the maximum for each and every contiguous sub-array of size… Read More »

## Find the Initial Array from given array after range sum queries

Given an array arr[] which is the resultant array when a number of queries are performed on the original array. The queries are of the… Read More »

## Check if a number can be expressed as sum two abundant numbers

Given a number N. The task is to express N as sum two Abundant Numbers. If it is not possible print -1. Examples: Input :… Read More »

## Find the sum of the all amicable numbers up to N

Given a number N. FInd the sum of he all amicable numbers up to N. If A and B are Amicable pairs (Two numbers are… Read More »