Scrambled String is broken?

  • 0

    My solution is a quick one liner- compare the sorted strings and return true if they're the same, false if they're not.

    class Solution:
    # @return a boolean
    def isScramble(self, s1, s2):
        return ''.join(sorted(s1))==''.join(sorted(s2))

    The result I get is:
    179 / 281 test cases passed.
    Status: Wrong Answer
    Submitted: 1 minute ago
    Input: "abcd", "bdac"
    Output: true
    Expected: false

    I don't see how "bdac" and "abcd" are different...?

  • 1

    It is impossible to scramble 'abcd' to 'bdac', since 'abcd' cannot split into 2 sub-string which has the same letters as 'bdac'.

Log in to reply

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