It’s me again. Here’s my solution.
function isValid(s) { const t = s.replace(/\(\)|\[\]|\{\}/g, ""); return s == t ? !s : isValid(t); };
Test it here: leetcode.com/problems/valid-parent...
As far as I know, the regex will manipulate string and string manipulation is a bit time consuming heavy in javascript.
But smart and concise code though !
It’s true. C/C++ can solve it in almost 0ms.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It’s me again. Here’s my solution.
Test it here: leetcode.com/problems/valid-parent...
As far as I know, the regex will manipulate string and string manipulation is a bit time consuming heavy in javascript.
But smart and concise code though !
It’s true. C/C++ can solve it in almost 0ms.