Data Structures & AlgorithmsHardGATE CS · CAT · MBA placement
Three fair six-faced dice are rolled. How many ordered outcomes (d1, d2, d3) have a total of exactly 10?
- A. 6
- B. 27
- C. 13
- D. 21
Correct answer: B. 27
Count with DP over the number of dice: each new die adds any face 1 to 6, so the order of results matters. Counting multisets (combinations with repetition) undercounts the ordered outcomes, which is the usual mistake.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many arrays of length 4 with entries from {1, 2, 3} have no two adjacent entries equal?
- Grid rows (top to bottom): '....', '.#..', '...#', '#...', '....'. '#' is an obstacle, '.' is free. Starting at the top-left cell, you…
- A triangle of numbers has rows [9], [7, 6], [9, 7, 4], [6, 1, 5, 3], [6, 9, 2, 4, 5]. Starting at the top, each step goes to one of the…
- How many non-empty contiguous subarrays of [-4, 2, -7, 5, -1, 3, -2, 6] have a sum divisible by 3 (the sum 0 counts as divisible)?
- A Java program stores dp[i] in an int array, sets dp[0] = dp[1] = 1, uses dp[i] = dp[i-1] + dp[i-2] for i up to 50, and never applies a…
- Words available: a, ab, b, ba, aa, abba, bab, aab. How many different ways can the string 'abbaaab' be split into a sequence of these…