param { string } s return { boolean } var isValidParentheses = function ( s ) : boolean { let stack = [ ] ; let arr = s . split ( '' ) ; let map = { '(' : ')' , '[' : ']' , '{' : '}' } ; for ( let i = 0 ; i < arr . length ; i ++ ) { if ( i === 0 ) { stack . push ( arr [ i ] ) ; } else { let stackEnd = stack [ stack . length - 1 ] ; if ( map [ stackEnd ] === arr [ i ] ) { stack . pop ( ) ; } else { stack . push ( arr [ i ] ) ; } } } if ( stack . length !== 0 ) { return false ; } else { return true ; } } ; export { isValidParentheses } ;