Data Structures & AlgorithmsHardICPC regional · GATE CS
Problem: The matrix [[1,2],[3,4]] is raised to the power 3 (matrix multiplication, not element-wise). What is the entry in row 0, column 0 of the result?
- A. 7
- B. 1
- C. 37
- D. 199
Correct answer: C. 37
M² = [[7,10],[15,22]] and M³ = [[37,54],[81,118]], so the top-left is 37. M² gives 7, cubing element-wise gives 1, and M⁴ gives 199.
More Coding Interview Problems questions
- Problem: Starting from the empty binary string, the value of the string "1011" read in base 2 is computed, then 3 is added. What is the…
- Problem: A list is [5, 9, 2, 7]. How many pairs (i, j) with i < j have a[i] + a[j] greater than 10?
- Problem: For the words ["sleep", "steep", "sheep", "creep"] (all of length five), how many unordered pairs differ in exactly one letter…
- Problem: The string "abcabc" is processed by replacing each character with its index in the alphabet (a=0, b=1, ..., z=25), and then the…
- Problem: A directed graph on vertices 0–4 has arcs 0→1 (2), 0→2 (6), 1→2 (3), 1→3 (9), 2→3 (1), 3→4 (2), 2→4 (8). What is the length of…
- Problem: Vertices 1–6 of an undirected graph have edges 1-2, 2-3, 4-5, 5-6, 6-4 and 3-1. How many edges are NOT part of any cycle?