# Category Archives: Algorithm

## Program to find smallest difference of angles of two parts of a given circle

Given a division of circle into n pieces as an array of size n. The i-th element of the array denotes the angle of one… Read More »

## Sexy Prime

In mathematics, Sexy Primes are prime numbers that differ from each other by six. For example, the numbers 5 and 11 are both sexy primes,… Read More »

## Even-odd turn game with two integers

Given three positive integers X, Y and P. Here P denotes the number of turns. Whenever the turn is odd X is multiplied by 2… Read More »

## Check if the game is valid or not

Three players P1, P2 and P3 are playing a game. But at a time only two players can play the game, so they decided, at… Read More »

## Find the number of stair steps

Given the total number of bricks T, find the number of stair steps that can be formed by using given bricks such that if step… Read More »

## Fast Fourier Transformation for poynomial multiplication

Given two polynomial A(x) and B(x), find the product C(x) = A(x)*B(x). There is already an O() naive approach to solve this problem. here. This… Read More »

## Sum of natural numbers using recursion

Given a number n, find sum of first n natural numbers. To calculate the sum, we will use a recursive function recur_sum(). Examples : Input… Read More »

## The painter’s partition problem | Set 2

We have to paint n boards of length {A1, A2, .. An}. There are k painters available and each takes 1 unit time to paint… Read More »

## Schröder–Hipparchus number

The Schröder–Hipparchus numbers form an integer sequence that can be used to count the number of plane trees with a given set of leaves, the… Read More »

## Sum of squares of first n natural numbers

Given N, find sum of squares of first N natural number. Examples : Input : n = 2 Output : 5 Explanation: 1^2+2^2 = 5… Read More »

## Leyland Number

In number theory, a Leyland number is a number of the form xy + yx, where x and y are integers greater than 1 and… Read More »

## Reverse bits using lookup table in O(1) time

Given an unsigned integer, reverse all bits of it and return the number with reversed bits. Examples: Input : n = 1 Output : 2147483648… Read More »

## Number of palindromic subsequences of length k

Given a string S of length n and a positive integer k. The task is to find number of Palindromic Subsequences of length k. Examples:… Read More »

## Check for integer overflow on multiplication

Given two integer a and b, find whether their product (a x b) exceed the signed 64 bit integer or not. If it exceed print… Read More »

## Program for volume of Pyramid

A pyramid is a 3-dimensional geometric shape formed by connecting all the corners of a polygon to a central apex. There are many types of… Read More »