Skip to content

올바른 괄호 #404

@fkdl0048

Description

@fkdl0048
#include<string>
#include <iostream>
#include <stack>

using namespace std;

bool solution(string s) {
    stack<char> st;
    
    for (char c : s) {
        if (c == '(') {
            st.push(c);
        } else {
            if (st.empty()) {
                return false;
            }
            st.pop();
        }

    }
    
    return st.empty();
}

Metadata

Metadata

Assignees

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions