Number of Distinct Roll Sequences
A hard-tier problem at 57% community acceptance, tagged with Dynamic Programming, Memoization. Reported in interviews at ServiceNow and 0 others.
You've hit the Number of Distinct Roll Sequences problem. It's a hard DP problem that shows up in ServiceNow assessments, and it has a solid acceptance rate around 57%, which means half the people who attempt it blank or time out. The trap is obvious at first, the brute force looks reasonable, and then you realize you're computing the same subproblems thousands of times. If you haven't internalized memoization patterns before your live OA, this is exactly where StealthCoder keeps you from burning 30 minutes on a failed greedy or recursive explosion.
Companies that ask "Number of Distinct Roll Sequences"
Number of Distinct Roll Sequences is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe problem requires you to count distinct sequences under some constraint, which immediately suggests dynamic programming with memoization. The naive recursive approach explodes exponentially because you're re-solving overlapping states. The trick is recognizing what your state actually is, how many unique states exist, and whether top-down memoization or bottom-up DP makes the recurrence clearer. Most people either implement the recursion correctly but forget memoization entirely, or they cache the wrong state signature and still hit redundant work. The pattern here touches both Dynamic Programming and Memoization as core mechanics, not ornaments. If you're unsure whether your state representation is minimal or if your recursion tree is actually getting pruned, that's the moment StealthCoder surfacing a working solution in seconds during your assessment becomes your safety net.
Pattern tags
You know the problem.
Make sure you actually pass it.
Number of Distinct Roll Sequences recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Number of Distinct Roll Sequences interview FAQ
How hard is this problem really, given the 57% acceptance rate?+
57% acceptance means it's genuinely hard. You need solid DP intuition and memoization discipline. The problem isn't a straightforward DP setup, so people often implement it wrong on the first pass or miss optimization entirely. It's not a gotcha problem, but it demands clean recursion and correct state caching.
What's the main pitfall that kills people on this one?+
Forgetting to memoize, or memoizing with the wrong state key. The recursive solution looks clean, but without proper caching you'll have exponential time complexity. Also common: picking a state representation that's correct but leaves redundant computation uncached because the key doesn't capture the minimal state boundary.
Is this still asked at ServiceNow?+
Yes. ServiceNow has reportedly asked this problem. It tests DP reasoning and implementation quality under time pressure. If you're interviewing there, having a solid memoization pattern drilled is essential, or you'll get stuck mid-attempt.
How does memoization relate to the solution here?+
Memoization is the difference between a solution that works and one that times out. The recursive structure is natural once you identify it, but you must cache results at the right granularity. Top-down memoization with a dictionary or map is the standard approach for this type of counting problem.
Should I implement this top-down or bottom-up?+
Top-down with memoization is easier to reason about for this problem. You write the recursion naturally, then add caching. Bottom-up requires you to figure out iteration order, which is harder when the state space isn't a simple grid. Start with memoized recursion unless you're very confident in bottom-up DP.
Want the actual problem statement? View "Number of Distinct Roll Sequences" on LeetCode →