Need help with problem definition for No.30 Substring with Concatenation of All Words

  • 0

    Hi, all

    I seemed to have problem understanding what "30 Substring with Concatenation of All Words" asks for.

    This is problem definition:
    You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.
    For example, given:
    s: "barfoothefoobarman"
    words: ["foo", "bar"],
    you should return the indices: [0,9].(order does not matter).

    From what I understand, I think the answer for input:
    s : "barfoofoobarthefoobarman"
    words : ["bar","foo","the"]
    should be [0,6,15] since 0 for "barfoo", 6 for "foobarthe", 15 for "foobar"

    However expected answer is:[6,9,12]. Could someone kindly help answer how come the expected answer is [6,9,12]?

    Thanks in advance!

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.