#2954

Count the Number of Infection Sequences

master · 1795 · lc hard +32 · 37.3% accepted · 147 likes · top 15%

Description

A line of n people has some initially infected positions given in the sorted array sick. Each step one uninfected neighbor of an infected person catches the disease, continuing until everyone is infected.

An infection sequence records the order non-initial people get infected.

Return the count of distinct infection sequences modulo 109 + 7.

Code

1
2
3