Tap here to switch tabs
Problem
Submissions

Problem: Shortest Impossible Sequence of Rolls

med
30 min
Try to solve the Shortest Impossible Sequence of Rolls problem.

Statement

You are given an integer array rolls of length n and an integer k, representing nn rolls of a die with faces numbered from 11 to k.

Return the length of the shortest sequence of rolls that cannot be formed from rolls.

Note: A sequence of rolls can be formed from rolls if it exists as a subsequence within rolls. A subsequence is derived by deleting zero or more elements from rolls without changing the relative order of the remaining elements.

Constraints:

  • n ==== rolls.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq rolls[i] ≤\leq k ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Shortest Impossible Sequence of Rolls

med
30 min
Try to solve the Shortest Impossible Sequence of Rolls problem.

Statement

You are given an integer array rolls of length n and an integer k, representing nn rolls of a die with faces numbered from 11 to k.

Return the length of the shortest sequence of rolls that cannot be formed from rolls.

Note: A sequence of rolls can be formed from rolls if it exists as a subsequence within rolls. A subsequence is derived by deleting zero or more elements from rolls without changing the relative order of the remaining elements.

Constraints:

  • n ==== rolls.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq rolls[i] ≤\leq k ≤105\leq 10^5