From 49a53605d36b7a95b9eed7e249af5cef11fabbb4 Mon Sep 17 00:00:00 2001 From: ritikakatoch Date: Thu, 13 Oct 2022 16:39:31 +0530 Subject: [PATCH] Added valid parentheses --- LeeCode_Problems/20.Valid_Parentheses.cpp | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 LeeCode_Problems/20.Valid_Parentheses.cpp diff --git a/LeeCode_Problems/20.Valid_Parentheses.cpp b/LeeCode_Problems/20.Valid_Parentheses.cpp new file mode 100644 index 0000000..6483aa4 --- /dev/null +++ b/LeeCode_Problems/20.Valid_Parentheses.cpp @@ -0,0 +1,49 @@ + +// Time Complexity: O(n); +//Space Complexity: O(n) //auxiliary space +#include +using namespace std; + +class Solution { +public: + bool isValid(string s) { + stack stk; + int i=0; + for(int i=0;i