Search⌘ K
AI Features

Index Pairs of a String

Explore how to efficiently find all index pairs in a string where substrings from a given list occur. This lesson guides you through using trie data structures to manage and search strings and teaches how to return sorted index pairs. By mastering this pattern, you will enhance your ability to solve substring search problems in coding interviews.

Statement

Given a string text and an array of strings words, return a list of all index pairs [i, j] such that the substring text[i...j] is present in words.

Return the pairs [i, j] in a sorted order, first by the value of i, and if two pairs have the same i, by the value of j.

Constraints:

  • 11 \leq ...