프로그래머스 올바른괄호
2022. 8. 17. 10:30ㆍ카테고리 없음
반응형
#include<string>
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
bool solution(string s)
{
bool answer = true;
stack <int> st;
for(int i = 0; i< s.size(); i++)
{
if (s[i] == '(')
st.push(1);
else
{
if (st.size() == 0)
return false;
st.pop();
}
}
if (st.empty() == 1)
return true;
else return false;
return answer;
}
25973