C++ code so elegant has no curly bracket


#1
    int Solution::solve(string A) {
        stack<char>s;
        for(auto i:A)
            if(i=='(')s.push(i);
            else if(s.empty()==0)s.pop();
            else return 0;
        return s.empty();
    }

#2

How about this one with out even the stack?

int Solution::solve(string A) {
    int open = 0;
    for(char ch:A)
        if(ch =='(') open++;
        else if(open) open--;
        else return 0;
    return !open;
}