CodeNFacts
CodeHub
Home

All Categories


Sign In
TECHNICAL PLACEMENT PREP

Aptitude & Reasoning for Coding Interviews

A complete reference kit covering essential Quantitative, Logical, and Data Reasoning concepts, formulas, Python shortcuts, and practice questions.

Quantitative

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)!)

e.g., Ways to choose 2 items from 5 = 5C2 = 10

Permutations Formula

nPr = n! / (n - r)!

e.g., Arrangements of 3 items from 5 = 5P3 = 60

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:

pythonShortcut Snippet
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}")

✍️ Practice Questions & Answers

Q1: In how many distinct ways can the letters of the word 'LOGIC' be arranged?

A) 60
B) 120
C) 240
D) 720

Q2: Find the greatest number that divides 122 and 243 leaving remainders 2 and 3 respectively.

A) 12
B) 24
C) 30
D) 40