## Largest number with maximum trailing nines which is less than N and greater than N-D

Given two numbers N and D. The task is to find out the largest number smaller than or equal to N which contains the maximum… Read More »

## Find gcd(a^n, c) where a, n and c can vary from 1 to 10^9

Question problem states that find gcd() of two numbers out of which one number can be as big as (10^9)^(10^9) which cannot be stored in… Read More »

## Sum of two numbers modulo M

Given three numbers A, B, and M. The task is to print the sum of A and B under modulo M. Examples: Input: a =… Read More »

## Sum of series till N-th term whose i-th term is i^k – (i-1)^k

Given value of N and K. The task is to find the sum of series till N-th term whose i-th term is given by Ti… Read More »

## Merge Sort with O(1) extra space merge and O(n lg n) time

We have discussed Merge sort. How to modify the algorithm so that merge works in O(1) extra space and algorithm still works in O(n Log… Read More »

## Find a string such that every character is lexicographically greater than its immediate next character

Given an integer N, the task is to find a string(considering only lowercase characters) of length (N+1) such that the character at any position should… Read More »

## Sudo Placement 2 | Matrix Series

A Matrix series is defined as follows: M, MT, M(MT), M(MT)2, M2(MT)3, M3(MT)5, M5(MT)8 . . . . . . . ., where M is a… Read More »

## Find (a^b)%m where ‘b’ is very large

Given three numbers a, b and m where 1<=a, m<=10^6. Given very large 'b' containing up to 10^6 digits and m is a prime number,… Read More »

## Queries of nCr%p in O(1) time complexity

Given Q queries and P where P is a prime number, each query has two numbers N and R and the task is to calculate… Read More »

## Minimum steps to reach end from start by performing multiplication and mod operations with array elements

Given start, end and an array of N numbers. At each step, start is multiplied with any number in the array and then mod operation… Read More »

## Compute power of power k times % m

Given x, k and m. Compute (xxxx…k)%m, x is in power k times. Given x is always prime and m is greater than x. Examples:… Read More »

## LCM of two large numbers

Given two large numbers ‘a’ and ‘b’ such that(10^20<=a, b<=10^300). Find the LCM of two large numbers given. Examples: Input: a = 234516789234023485693020129 b =… Read More »

## Product of first N factorials

Given a number N. Find the product of first N factorials modulo 1000000007. Constraints: 1 ≤ N ≤ 1e6 Examples: Input : 3 Output :… Read More »

## Trick for modular division ( (x1 * x2 …. xn) / b ) mod (m)

Given integers x1, x2, x3……xn, b and m, we are supposed to find the result of ((x1*x2….xn)/b)mod(m). Example 1 : Suppose that we are required… Read More »

## Divisibility by 3 where each digit is the sum of all prefix digits modulo 10

Given K, number of digits, and d0 and d1 as the two digits to form the k-sized integer. Task is to check whether the k-sized… Read More »