Skip to content

Instantly share code, notes, and snippets.

@vlas-ilya
Created October 9, 2015 12:20
Show Gist options
  • Save vlas-ilya/b80d91bb76dcfcf91c19 to your computer and use it in GitHub Desktop.
Save vlas-ilya/b80d91bb76dcfcf91c19 to your computer and use it in GitHub Desktop.
var isCorrectParentheses = function (str) {
var i = 0;
for (var ch = 0; ch < str.length; ch++) {
if (str[ch] === '(') i++;
if (str[ch] === ')') i--;
if (i < 0) return false;
}
if (i !== 0) return false;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment