-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunderstandingClass.cpp
More file actions
46 lines (41 loc) · 1015 Bytes
/
understandingClass.cpp
File metadata and controls
46 lines (41 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
class callName {
public:
string Name;
int age;
string subject;
int number;
callName(string name1, int age1, string sub, int num){
Name=name1;
age=age1;
subject=sub;
number=num;
}
void recallName(){
cout<< "Name:"<<Name<<" Age:"<<age;
}
};
bool removeOuterParentheses(string ch) {
stack<char>st;
for (int i =0;i<ch.length();i++) {
if (ch[i] == '(' || ch[i] == '[' || ch[i] == '{') {
st.push(ch[i]);
} else {
if (st.empty()) return false;
char top = st.top();
st.pop();
if ((ch[i] == ')' && top != '(') || (ch[i] == ']' && top != '[') || (ch[i] == '}' && top != '{')) {
return false;
}
}
}
return st.empty();
}
int main(){
callName n1("sohil", 24, "cpp", 100);
// n1.recallName();
string s = "(()())()[])";
cout<<removeOuterParentheses(s);
return 0;
}