โ† LinkedIn questions

Count sequences of 1s, 2s, 3s, and 4s with no adjacent duplicates

Filed under LinkedIn

The question

Given counts `n1`, `n2`, `n3`, and `n4` of numbers 1, 2, 3, and 4 respectively, find the number of valid sequences using all these numbers such that no two adjacent elements are the same. Output the result modulo 10^9 + 7.

No write-up yet. Related questions below have one.

Related LinkedIn questions

Collected from public candidate posts and coding forums. Updated Nov 2026.