Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
For each position we simply need to find the first occurrence of a/b/c on or after this position.
So we can pre-compute three link-list of indices of each a, b, and c.