Data Structures & AlgorithmsHardTCS NQT · probability
Problem: Two fair six-sided dice are rolled. What is the expected value of the larger of the two faces (the maximum)?
- A. 7/2
- B. 4.5
- C. 161/36
- D. 126/36
Correct answer: C. 161/36
P(max <= k) = (k/6)^2, so E[max] = sum over k of (1 - (k/6)^2) for k = 0..5, which equals 161/36 (about 4.47). The average of the two values (7/2) is the trap.
More Coding Interview Problems questions
- Problem: Words apple, app, apt, bat, banana are stored in a trie that keeps a count of words passing through each node. What does the code…
- Problem: The longest subarray with equally many 0s and 1s of a = [0, 1, 0, 0, 1, 1, 0] is needed. Run the prefix-balance code and print…
- Problem: Find the 3 smallest pair sums from A = [1, 7, 11] and B = [2, 4, 6], using a heap that starts with each A element paired with…
- Problem: An undirected connected graph has an Euler circuit (a closed walk using every edge exactly once) if and only if which condition…
- Problem: Using 2D prefix sums on M = [[1,2,3],[4,5,6],[7,8,9]], what is the sum of the rectangle with rows 1..2 and columns 1..2…
- Problem: How many pairs (i < j) of a = [1, 2, 3, 4, 5, 6, 7] have a[i] + a[j] divisible by 4? python a = [1, 2, 3, 4, 5, 6, 7] print(sum(1…