leetcode new problems

This commit is contained in:
2026-02-11 14:48:41 +05:30
parent 192ce44a81
commit 0f52d46c67
29 changed files with 658 additions and 5 deletions
+17
View File
@@ -0,0 +1,17 @@
class Solution {
public:
bool isValid(string s) {
stack<char> st;
unordered_map<char,char> mapping = {{')','('}, {'}','{'}, {']','['}};
for(char c: s){
if(mapping.find(c) == mapping.end()) st.push(c);
else if(!st.empty() && mapping[c] == st.top()) st.pop();
else return false;
}
return st.empty();
}
};