eolymp
bolt
Try our new interface for solving problems
Problems

Bracket sequence

published at 4/27/23, 10:54:08 pm

and what's the inputs in 14th and 28th tests

published at 3/31/24, 7:01:42 pm

#16390704 //with stack

include <iostream>

include <stack>

using namespace std; int main() { stack<char> st; bool yoxla = false; string moterize; cin>>moterize; for(int i = 0; i < moterize.length(); i++) { if(moterize[i] == '(')st.push('('); else if(moterize[i]==')') { if(st.empty()) { yoxla = true; break; } st.pop(); } } if(!yoxla && st.empty()) cout << "YES\n"; else cout <<"NO\n"; return 0; }