13분 컷,,,쉽게 통과함. 스택을 이용했음 #include #include #include using namespace std; void solution(string input) { int ssz = input.length(); stack balance; for (int sz = 0; sz < ssz; ++sz) { if (balance.empty()) { if (input[sz] == ')') { cout << "NO" << '\n'; return; } balance.push('('); continue; } if (input[sz]==')') { balance.pop(); } else { balance.push('('); } } if (!
balance.empty()) { cout << "NO" << '\n'; return; } else cout << "YES" << '\n'; } int main() { int tc; ...
원문 링크 : 백준 - 괄호