Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: A grid has 3 rows and 4 columns. Starting at (0,0), a move goes right or down, and cells with odd row+column are forbidden. How many valid paths reach (2,3)?
- A. 1
- B. 2
- C. 0
- D. 3
Correct answer: C. 0
Path DP where forbidden cells hold zero. Note that the target (2,3) has odd parity, so the answer is 0; this sanity check catches the trap of assuming the forbidden rule only applies to intermediate cells.
More Coding Interview Problems questions
- Problem: For the words ["bella", "label", "roller", "dinner", "ladder"], how many pairs (i, j) with i < j are anagrams of each other (same…
- Problem: The number 2024 is factorised. How many positive integers less than 10000 are divisors of 2024 × 2025?
- Problem: How many subarrays of [1, 2, 3, 1, 2, 3, 4] contain exactly 3 distinct values? Run the brute-force code. python a = [1, 2, 3, 1…
- Problem: How many integers in [1, 1000] are divisible by 7, 11 or 13? Run the code. python print(sum(1 for x in range(1, 1001) if x % 7 ==…
- Problem: What is the number of trailing zeros in 2025! (in decimal)? Run the code. python n = 2025 c = 0 p = 5 while p <= n: c += n // p p…
- Problem: What is the sum of all distinct prime factors of 2025? Run the code. python n = 2025 f = 2 ps = set() while f f <= n: while n % f…