Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
If substring <code>[i, j]</code> is valid, then for all <code>k >= j, [i, k]</code> is valid too.
For each <code>i</code>, find <code>j</code> with a sliding window or binary search.