# Category Archives: Algorithms

## Find if string is K-Palindrome or not | Set 2

Given a string, find out if the string is K-Palindrome or not. A K-palindrome string transforms into a palindrome on removing at most k characters… Read More »

## Almost Prime Numbers

A k-Almost Prime Number is a number having exactly k prime factors (not necessary distinct). For example, 2, 3, 5, 7, 11 ….(in fact all… Read More »

## Program to add two fractions

Add two fraction a/b and c/d and print answer in simplest form. Examples : Input: 1/2 + 3/2 Output: 2/1 Input: 1/3 + 3/9 Output:… Read More »

## Roots of Unity

Given a small integer n, print all the n’th roots of unity up to 6 significant digits. We basically need to find all roots of… Read More »

## Converting Roman Numerals to Decimal lying between 1 to 3999

Given a Romal numeral, the task is to find its corresponding decimal value. Example : Input: IX Output: 9 IX is a Roman symbol which… Read More »

## The Lazy Caterer’s Problem

Given an integer n, denoting the number of cuts that can be made on a pancake, find the maximum number of pieces that can be… Read More »

## Program to convert a given number to words | Set 2

Write code to convert a given number into words. Examples: Input: 438237764 Output: forty three crore eighty two lakh thirty seven thousand seven hundred and… Read More »

## Count digits in a factorial | Set 2

Given an integer n (can be very large), find the number of digits that appear in its factorial, where factorial is defined as, factorial(n) =… Read More »

## Count digits in a factorial | Set 1

Given an integer n, find the number of digits that appear in its factorial, where factorial is defined as, factorial(n) = 1*2*3*4……..*n and factorial(0) =… Read More »

## Find Surpasser Count of each element in array

A surpasser of an element of an array is a greater element to its right, therefore x[j] is a surpasser of x[i] if i <… Read More »

## Printing Shortest Common Supersequence

Given two strings X and Y, print the shortest string that has both X and Y as subsequences. If multiple shortest supersequence exists, print any… Read More »

## Printing Longest Common Subsequence | Set 2 (Printing All)

Given two sequences, print all longest subsequence present in both of them. Examples: Input: string X = “AGTGATG” string Y = “GTTAG” Output: GTAG GTTG… Read More »

## Palindrome Substring Queries

Given a string and several queries on the substrings of the given input string to check whether the substring is a palindrome or not. Examples… Read More »

## Match a pattern and String without using regular expressions

Given a string, find out if string follows a given pattern or not without using any regular expressions. Examples: Input: string – GraphTreesGraph pattern -… Read More »

## Compute (a*b)%c such that (a%c) * (b%c) can be beyond range

Given three numbers a, b and c such that a, b and c can be at most 1016. The task is to compute (a*b)%c A… Read More »