# Category Archives: Algorithm

## Least Common Denominator (LCD)

The lowest Common Denominator or Least Common Denominator is the Least Common Multiple of the denominators of a set of fractions. Common denominator : when… Read More »

## Pairs with Difference less than K

Given an array of n integers, We need to find all pairs with difference less than k Examples: Input : a[] = {1, 10, 4,… Read More »

## Ways to select one or more pairs from two different sets

Given two positive numbers ‘n’ and ‘m’ (n <= m) which represent total number of items of first and second type of sets respectively. Find… Read More »

## Lexicographically largest subsequence such that every character occurs at least k times

Given a string S and an integer K. The task is to find lexicographically largest subsequence of S, say T, such that every character in… Read More »

## Minimum tiles of sizes in powers of two to cover whole area

Given an area of N X M. You have infinite number of tiles of size 2i X 2i, where i = 0, 1, 2,… so… Read More »

## Vampire Number

Introduction to Vampire Number and its implementation using python. Introduction In mathematics, a vampire number (or true vampire number) is a composite natural number v,… Read More »

## Count of numbers satisfying m + sum(m) + sum(sum(m)) = N

Given an integer N, find out the count of numbers(m) that satisfy the condition m + sum(m) + sum (sum(m)) = N, where sum(m) denotes… Read More »

## GCD of digits of a given number

Given a number n, find GCD of its digits. Examples: Input : 345 Output : 1 GCD of 3, 4 and 5 is 1. Input… Read More »

## Check if a number is power of k using base changing method

This program checks whether a number n can be expressed as power of k and if yes, then to what power should k be raised… Read More »

## Ways to color a 3*N board using 4 colors

Given a 3 X n board, find the number of ways to color it using at most 4 colors such that no two adjacent boxes… Read More »

## Check if number is palindrome or not in Octal

Given a number which may be in octal or in decimal. If the number is not octal then convert it into octal then check if… Read More »

## Find all factorial numbers less than or equal to n

A number N is called a factorial number if it is the factorial of a positive integer. For example, the first few factorial numbers are… Read More »

## Sort a Rotated Sorted Array

You are given a rotated sorted array and your aim is to restore its original sort in place. Expected to use O(1) extra space and… Read More »

## Circle Sort

Circle sort algorithm can be visualized by drawing concentric circles on an array of integers. The elements of the array lying on the same circle… Read More »

## Happy Numbers

A Happy Number n is defined by the following process. Starting with n, replace it with the sum of the squares of its digits, and… Read More »