tree appears somewhere in it as consecutive letters. For example, etrex is lucky (xtree), while trex is not: it has only one e.
Given length, count how many lucky strings of exactly that length exist. The number can be huge, so return it modulo 10⁹ + 7.length=4 → 12
A four-letter string must consist of exactly t, r, e, e. There are 4! / 2! = 12 arrangements of these letters.
length=3 → 0
Four required letters cannot fit into three positions.
length=5 → 1460
length ≤ 10⁵length=4
12
Run checks the first 3 tests in your browser. Submit checks all 24 tests on the server, hidden ones included.