Practice Shortest Impossible Sequence of Rolls
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an integer array rolls of length n and an integer k. You roll a k sided dice numbered from 1 to k, n times, where the result of the ith roll is rolls[i]. Return the length of the shortest sequence of rolls so that there's no such subsequence in rolls. A sequence of rolls of length len is the result of rolling a k sided dice len times.
Source: Shortest Impossible Sequence of Rolls on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
rolls = [4,2,1,2,3,3,2,4,1], k = 4
3
# Example 2
rolls = [1,1,2,2], k = 2
2
# Example 3
rolls = [1,1,3,2,2,2,3,3], k = 4
1
Constraints
Related LeetCode Problems
Practice more problems similar to Shortest Impossible Sequence of Rolls.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.