# Category Archives: Competitive Programming (adsbygoogle = window.adsbygoogle || []).push({});

## 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 possibe 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 »

## Largest sub-set possible for an array satisfying the given condition

Given an array arr[] and an integer K. The task is to find the size of the maximum sub-set such that every pair from the… Read More »

## Minimum multiplications with {2, 3, 7} to make two numbers equal

Given two numbers A and B, the task is to find the minimum number of operations required to make A and B equal. In each… Read More »

## Possible cuts of a number such that maximum parts are divisible by 3

Given a Large number N ( number of digits in N can be up to 105). The task is to find the cuts required of… Read More »

## Count distinct substrings that contain some characters at most k times

Given a integer k and a sting str, the task is to count the number of distinct sub-strings such that each sub-string does not contain… Read More »