missing test case


  • 0
    A
    var isValid = function(s) {
        var mapping = {
          '(': ')',
          ')': '(',
          '[': ']',
          ']': '[',
          '{': '}',
          '}': '{'
        };
    
        var stack = [];
    
        var len = s.length;
        while (len > -1) {
            len--;
          var tempChar = s.charAt(len);
    
          if (mapping[tempChar]){
            if (mapping[tempChar] === stack[stack.length - 1]) {
              stack.pop();
            } else {
              stack.push(tempChar);
            }
          } 
        }
    
        return stack.length ? false : true;
    };
    

    this is my js code!
    can not test right for ')(', '][' and so on,but got 'ACCEPT' result;


Log in to reply
 

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