You are viewing a single comment's thread. Return to all comments →
C# Equivalent:
static string matchBrackets(char[] chars){ Stack s = new Stack(); foreach(char c in chars){ if(c== '{') s.Push('}'); else if(c== '(') s.Push(')'); else if(c== '[') s.Push(']'); else { if (s.Count == 0 || c != (char)s.Peek()) return "NO"; s.Pop(); } } return s.Count == 0 ? "YES": "NO"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Stacks: Balanced Brackets
You are viewing a single comment's thread. Return to all comments →
C# Equivalent: