50+ curated coding problems frequently asked in Deloitte interviews with detailed solutions
Given a sequence of ranks of students, count how many times the current rank is less than any previous rank (i.e., how many times you need to "cut the name" because someone with better rank came before).
Input: ranks = [5, 2, 7, 3, 1] Output: 6 Explanation: - At index 1 (rank 2): cuts 1 name (rank 5) - At index 3 (rank 3): cuts 2 names (ranks 5, 7) - At index 4 (rank 1): cuts 3 names (ranks 5, 7, 3) Total = 1 + 2 + 3 = 6
Given an array of decimal numbers, remove 'n' least significant binary bits from each number and output the new decimal values.
Input: numbers = [25, 18, 33], n = 2 Output: [6, 4, 8] Explanation: 25 = 11001 (binary) ā Remove 2 LSBs ā 110 (binary) = 6 (decimal) 18 = 10010 (binary) ā Remove 2 LSBs ā 100 (binary) = 4 (decimal) 33 = 100001 (binary) ā Remove 2 LSBs ā 1000 (binary) = 8 (decimal)
Count how many numbers less than n have exactly k set bits in their binary representation.
Input: n = 10, k = 2 Output: 4 Explanation: Numbers < 10 with exactly 2 set bits: 3 = 11 (binary) - has 2 set bits ā 5 = 101 (binary) - has 2 set bits ā 6 = 110 (binary) - has 2 set bits ā 9 = 1001 (binary) - has 2 set bits ā Total = 4
Given a linked list where each node has mass (m) and velocity (v), compute total momentum = sum(m*v) for all nodes.
Input: LinkedList with nodes: Node 1: mass=2, velocity=3 Node 2: mass=5, velocity=2 Node 3: mass=1, velocity=10 Output: 26 Explanation: Total momentum = (2*3) + (5*2) + (1*10) = 6 + 10 + 10 = 26
We're continuously adding more coding problems. Check back regularly for updates!
Additional topics include: Lazy String (LCS), Prime Sum, Perfect Numbers, Sorting Algorithms, and many more...