#3699

Number of ZigZag Arrays I

international master · 1910 · lc hard +32 · 32.9% accepted · 82 likes · top 10%

Description

Given integers n, l, and r, count all length-n arrays with elements in [l, r] where no two adjacent elements are equal and no three consecutive elements form a strictly monotone sequence; return the count modulo 109 + 7.

Code

1
2
3