← All problemsSign in

2318. Number of Distinct Roll Sequences

LeetCodeDynamic ProgrammingMemoizationOpen on judge ↗

You are given an integer n. You roll a fair 6-sided dice n times. Determine the total number of distinct sequences of rolls possible such that the following conditions are satisfied: - The greatest common divisor of any adjacent values in the sequence is equal to 1. - There is at least a gap of 2 rolls between equal valued rolls. More formally, if the value of the ith roll is equal to the value

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start