Does the question assume proper prefix?

  • 0

    I am getting following

    Input: ["a","a","b"]
    Output: "a"
    Expected: ""

    "a" is indeed a prefix of itself? Does the question assume can it only be proper prefix?

  • 0

    Now if I modify the code such that it works only for proper prefixes then it gives the following:

    Input: ["c","c"]
    Output: ""
    Expected: "c"

    Now both can't be right. Is it possible that I have misunderstood the question? I assume we are finding the longest prefix among all pairs of strings in the given array of strings.

Log in to reply

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