leetcode-js | 用 JS 刷 LeetCode | Learning library
kandi X-RAY | leetcode-js Summary
kandi X-RAY | leetcode-js Summary
用 JS 刷 LeetCode
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of leetcode-js
leetcode-js Key Features
leetcode-js Examples and Code Snippets
Community Discussions
Trending Discussions on leetcode-js
QUESTION
I've a simple problem,
Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting parentheses string is valid.
Formally, a parentheses string is valid if and only if: It is the empty string, or It can be written as AB (A concatenated with B), where A and B are valid strings, or It can be written as (A), where A is a valid string. Given a parentheses string, return the minimum number of parentheses we must add to make the resulting string valid.
This is my solution in JS,
...ANSWER
Answered 2019-Jan-13 at 19:01A String
is not an Array
: it doesn't have the same methods.
However, you can use S.split("")
to get an array and then map
over it
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install leetcode-js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page