Given a string containing just the characters '('
, ')'
, '{'
, '}'
, '['
and ']'
, determine if the input string is valid.
The brackets must close in the correct order, "()"
and "()[]{}"
are all valid but "(]"
and "([)]"
are not.
class Solution {public: bool isValid(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function int l1=0,l2=0,l3=0; for(int i=0;i0||l2>0||l3>0)return false; return true; }};