Search
⌘K

Leetcode 3008. Find Beautiful Indices in the Given Array II

Find all start indices i where substring a occurs in s and there exists a start j where substring b occurs with |j − i| ≤ k. With s up to 5e5, this requires finding all occurrences of a and b (e.g., linear scan/KMP) and then checking proximity efficiently (two-pointer, binary search, or prefix array).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.