Tap here to switch tabs
Problem
Submissions

Problem: Shortest Impossible Sequence of Rolls

Shortest Impossible Sequence of Rolls asks you to use an array of die rolls, with faces from one to k, to find the length of the shortest sequence that is not a subsequence of the rolls.

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

Shortest Impossible Sequence of Rolls asks you to use an array of die rolls, with faces from one to k, to find the length of the shortest sequence that is not a subsequence of the rolls.

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