Aptitude & Reasoning for Coding Interviews
A complete reference kit covering essential Quantitative, Logical, and Data Reasoning concepts, formulas, Python shortcuts, and practice questions.
1. Number Theory & Combinatorics
Core fundamentals covering Modular Arithmetic, Divisibility, Permutations, and Combinations. Essential for array manipulation, hashing, and counting problems in coding.
📐 Core Rules & Formulas
Combinations Formula
nCr = n! / (r! * (n - r)!)
Permutations Formula
nPr = n! / (n - r)!
Sum of First N Natural Numbers
Sum = n * (n + 1) / 2
GCD x LCM Relation
A * B = GCD(A, B) * LCM(A, B)
⚡ Algorithmic Solution / Code Trick
Fast Python implementations for GCD, LCM, and Combinations:
import math
# 1. Fast GCD and LCM
a, b = 12, 18
gcd_val = math.gcd(a, b)
lcm_val = math.lcm(a, b) # Python 3.9+
print(f"GCD: {gcd_val}, LCM: {lcm_val}")
# 2. Permutations & Combinations
n, r = 5, 2
combinations = math.comb(n, r) # 5C2 = 10
permutations = math.perm(n, r) # 5P2 = 20
print(f"5C2: {combinations}, 5P2: {permutations}")
# 3. Sum of N numbers efficiently - O(1) time
n = 100
total_sum = n * (n + 1) // 2
print(f"Sum 1 to 100: {total_sum}")