Interview Question

Example 1:

String: " This is paragraph one "

List of substring: ["This", "is paragraph", "one"]

I need to return the index for the corresponding substring

Result: [[0,4], [5, 17], [18, 21]]

Example 2:
(Could have more white space and could have duplicate substring)

String:
"
This is a book a book.
"

List:
List of substring: ["This", "is a", "book", "a", "book"]

Result: [[0,4], [5, 9], [10, 14], [21,22], [23, 27]]

Comments (0)