Category Archives: Competitive Programming

Next greater number than N with exactly one bit different in binary representation of N

Given a number N. The task is to find the smallest number which is greater than N and has only one bit different in the… Read More »

A competitive programmer’s interview

How long have u been a competitive programmer? About 9 years. Top two websites you prefer to compete? Codingame, Topcoder What are some of the… Read More »

Understanding The Coin Change Problem With Dynamic Programming

The Coin Change Problem is considered by many to be essential to understanding the paradigm of programming known as Dynamic Programming. The two often are… Read More »

Queries for number of elements on right and left

Given Q queries of three types where every query consists of a number. Add element num on the left Add element num on the right… Read More »

Rearrange the string to maximize the number of palindromic substrings

Given a string S consisting of lowercase characters(a-z) only, the task is to print a new string by rearranging the string in such a way… Read More »

Queries to add, remove and return the difference of maximum and minimum.

Given Q queries. The queries are of three types and are described below: Add the number num to the list. Remove the number num from… Read More »

Find ‘N’ number of solutions with the given inequality equations

Find the value of a1, a2, a3, ….an such that the following two conditions are satisfied. Print the value of a1, a2, …, an and… Read More »

Number of balanced bracket subsequence of length 2 and 4

Given a bracket sequence of even length. The task is to find how many ways are there to make balanced bracket subsequences from the given… Read More »

Number of different positions where a person can stand

A person stands in line of n people, but he doesn’t know exactly which position he occupies. He can say that there are no less… Read More »

Find the direction from given string

Given a string of containing only L’s and R’s which represents left rotation and right rotation respectively. The task is to find the final direction… Read More »

Minimum increment in the sides required to get non-negative area of a triangle

Given three sides of the triangle, find the minimum increase in the length of the side of the triangle to make the area of the… Read More »

Count the number of carry operations required to add two numbers

Given two numbers, the task is to find the number of carry operations required when two numbers are added as below. 1234 + 5678 ——–… Read More »

Number of values of b such that a = b + (a^b)

Given an integer . Find the number of solutions of which satisfies the equation: a = b + (a^b) Examples: Input: a = 4 Output:… Read More »

Find two distinct prime numbers with given product

Given a number N (greater than 2 ). The task is to find two distinct prime numbers whose product will be equal to the given… Read More »

Number of Co-prime pairs from 1 to N with product equals to N

Given a number N. The task is to find the number of co-prime pairs (a, b) from 1 to N such that their product(a*b) is… Read More »