The algorithm is linear in the sense that each step only depends on the previous accumulator and the current character. We can solve for each character backwards:
The algorithm is linear in the sense that each step only depends on the previous accumulator and the current character. We can solve for each character backwards: