diff --git a/LeeCode_Problems/1653.minimumDeletionsToMakeStringBalanced.cpp b/LeeCode_Problems/1653.minimumDeletionsToMakeStringBalanced.cpp new file mode 100644 index 0000000..de41373 --- /dev/null +++ b/LeeCode_Problems/1653.minimumDeletionsToMakeStringBalanced.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +class Solution { +public: + int minimumDeletions(string s) { + int bcount=0; + int del=0; + for(int i=0;i0){ + bcount--; + del++; + } + if(s[i]=='b'){ + bcount++; + } + } + return del; + } +}; \ No newline at end of file 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