Count number of ways to partition a set into k subsets

Given two numbers n and k where n represents number of elements in a set, find number of ways to partition the set into k… Read More »

Modular Exponentiation (Power in Modular Arithmetic)

Given three numbers x, y and p, compute (xy) % p. Examples : Input: x = 2, y = 3, p = 5 Output: 3… Read More »

MakeMyTrip Interview Experience | Set 8 (On-Campus)

MakeMyTrip recently visited our campus. There were 4 rounds. Online Round ( 1 Hour ) This round consisted of 20 aptitude questions and 3 coding… Read More »

MakeMyTrip Interview Experience | Set 7 (On-Campus)

Recently makemytrip visited our Campus and I got selected in recruitment drive.The placement drive consisted of 4 rounds. Round1: MCQ and coding round It was… Read More »

MakeMyTrip Interview Experience | Set 6 (Online Coding)

Round-1: Online test There were 2 sections – Aptitude and Coding Section A- 20 MCQ’s on General Aptitude. Section B- There were 3 coding questions.… Read More »

How to compute mod of a big number?

Given a big number ‘num’ represented as string and an integer x, find value of “num % x” or “num mod x”. Output is expected… Read More »

Modular multiplicative inverse

Given two integers ‘a’ and ‘m’, find modular multiplicative inverse of ‘a’ under modulo ‘m’. The modular multiplicative inverse is an integer ‘x’ such that.… Read More »

Euler’s Totient Function

Euler’s Totient function ?(n) for an input n is count of numbers in {1, 2, 3, …, n} that are relatively prime to n, i.e.,… Read More »

Program to find remainder without using modulo or % operator

Given two numbers ‘num’ and ‘divisor’, find remainder when ‘num’ is divided by ‘divisor’. The use of modulo or % operator is not allowed. Examples… Read More »

Measure one litre using two vessels and infinite water supply

There are two vessels of capacities ‘a’ and ‘b’ respectively. We have infinite water supply. Give an efficient algorithm to make exactly 1 litre of water in one of the vessels.

Rabin-Karp Algorithm for Pattern Searching

Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may… Read More »

Program for Fibonacci numbers

The Fibonacci numbers are the numbers in the following integer sequence. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..… Read More »

Write a program to reverse digits of a number

Write a program to reverse digits of an integer. Examples : Input : num = 12345 Output : 54321 Input : num = 876 Output… Read More »

Write a program to calculate pow(x,n)

Given two integers x and n, write a function to compute xn. We may assume that x and n are small and overflow doesn’t happen.… Read More »