Javascript solution, extremely simple, but don't understand why it works


  • 0
    Y
    /**
     * @param {string} s
     * @param {string} p
     * @return {boolean}
     */
    var isMatch = function(s, p) {
        var reg = new RegExp('^' + p + '$')
        return reg.test(s)
    };
    

    That's all, I just add a start tag and a end tag, and it should pass the test! I don't think it should be that simple, I must have missed some test case.
    Anybody tell me where the problem is?


Log in to reply
 

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