#include<string>
#include<stack>
#include <iostream>
using namespace std;
bool solutioneke(string s)
{
bool answer = true;
stack<char> arr;
for (char i : s) {
if (i == '(') {
arr.push(i);
}
else {
if (arr.empty()) {
answer = false;
return answer;
}
arr.pop();
}
}
if (!arr.empty())
answer = false;
return answer;
}
int main() {
string s;
cin >> s;
if (solutioneke(s))
cout << "true" << endl;
else
cout << "false" << endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: