Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE
Problem: Count the longest increasing subsequences (subsequences of maximum length, strictly increasing) of [1, 3, 5, 4, 7]. Two index sets count as different even if the values match.
- A. 3
- B. 2
- C. 1
- D. 4
Correct answer: B. 2
Track both the LIS length ending at each index and how many ways achieve it. Counting only one optimal subsequence, or all increasing subsequences, gives a different count.
More Coding Interview Problems questions
- Problem: Snakes and ladders on squares 1–30: from square s, a die roll of r moves you to s + r (for 1 ≤ r ≤ 6, if s + r ≤ 30). Ladders…
- Problem: Nim with three piles of sizes 1, 2 and 3. A move removes any positive number of stones from one pile. The player who takes the…
- Problem: How many subarrays of [1, 2, 3, 0, 3, 2, 1] have a XOR of zero?
- Problem: How many integers from 1 to 50 have exactly two 1-bits in their binary representation?
- Problem: What is the sum of the decimal digits of 9⁹?
- Problem: Arrange the numbers 3, 30, 34, 5, 9 so that their decimal concatenation is the largest possible number. What is that largest…