Skip to content

Instantly share code, notes, and snippets.

@abhinavnigam2207
Created February 22, 2017 13:08
Show Gist options
  • Save abhinavnigam2207/f6df6e8a1d95f248edb7762360d9d901 to your computer and use it in GitHub Desktop.
Save abhinavnigam2207/f6df6e8a1d95f248edb7762360d9d901 to your computer and use it in GitHub Desktop.
Bracket Problem (Asked in Toptal Interview )
'use strict';
function solution(S) {
var arr = [];
var K = 0;
for (var i=0; i<S.length; i++) {
if (S[i]=='(') {
arr.push(S[i]);
} else {
if(arr.length){
arr.pop();
}
K++;
}
}
return K;
}
@prrraveen
Copy link

Hi abhinav,
Thanks for sharing. what were the other two problems? I am preparing for Toptal. I would like to know the difficulty level of problems asked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment