diff --git a/Amazon/Q7-Valid Parentheses b/Amazon/Q7-Valid Parentheses index 8cb325a..1286390 100644 --- a/Amazon/Q7-Valid Parentheses +++ b/Amazon/Q7-Valid Parentheses @@ -26,72 +26,34 @@ SOLUTION : Language - C++ -#include - -using namespace std; - -bool isclose(char c) -{ - return (c == ')' || c == '}' || c == ']'); -} -bool valid_Parenthese(string s) -{ + bool isValid(string s) { stack st; - map m; - m['('] = ')'; - m['{'] = '}'; - m['['] = ']'; - for (auto c : s) - { - if (isclose(c)) - { - if (st.empty()) - return false; - if (m[st.top()] == c) - { - st.pop(); - } - else - { - return false; - } - } - else - { - st.push(c); - } + int i=0; + while(i