## Products of ranges in an array

Given an array A[] of size N. Solve Q queries. Find the product in range [L, R] under modulo P ( P is Prime). Examples… Read More »

## Exponential Squaring (Fast Modulo Multiplication)

Given two numbers base and exp, we need to compute baseexp under Modulo 10^9+7 Examples: Input : base = 2, exp = 2 Output :… Read More »

## Subsequences of size three in an array whose sum is divisible by m

Given an array A[] (1<=A<=10) of size N (1<=N<=10), find number of subsequences of length 3 whose sum is divisible by M (1<=M<=10). Examples: Input… Read More »

## Program for product of array

Given an array, find product of all array elements. Examples : Input : ar[] = {1, 2, 3, 4, 5} Output : 120 Product of… Read More »

## Print k numbers where all pairs are divisible by m

Given an integer array and two numbers k and m. Print k numbers from the array, such that difference between any two pairs is divisible… Read More »

## Distributing M items in a circle of size N starting from K-th position

M items are to be delivered in a circle of size M. Find the position where the M-th item will be delivered if we start… Read More »

## Find modular node in a linked list

Given a singly linked list and a number k, find the last node whose n%k == 0, where n is the number of nodes in… Read More »

## Print last k digits of a^b (a raised to power b)

Given positive integers k, a and b we need to print last k digits of a^b ie.. pow(a, b). Input Constraint: k <= 9, a… Read More »

## Discrete logarithm (Find an integer k such that a^k is congruent modulo b)

Given three integers a, b and m. Find an integer k such that where a and m are relatively prime. If it is not possible… Read More »

## Find all pairs (a, b) in an array such that a % b = k

Given an array with distinct elements, the task is to find the pairs in the array such that a % b = k, where k… Read More »

## Finding ‘k’ such that its modulus with each array element is same

Given an array of n integers .We need to find all ‘k’ such that arr[0] % k = arr[1] % k = ……. = arr[n-1]… Read More »

## Find count of digits in a number that divide the number

Given a positive integer n. The task is to find count of digits of number which evenly divides the number n. Examples: Input : n… Read More »

## Maximum modulo of all the pairs of array where arr[i] >= arr[j]

Given an array of n integers. Find the maximum value of arr[i] mod arr[j] where arr[i] >= arr[j] and 1 <= i, j <= n… Read More »

## Multiply two numbers represented by Linked Lists

Given two numbers represented by linked lists, write a function that returns the multiplication of these two linked lists. Examples: Input : 9->4->6 8->4 Output… Read More »

## Fibonacci modulo p

The Fibonacci sequence is defined as = + where = 1 and = 1 are the seeds. For a given prime number p, consider a… Read More »