C++ || Detailed Explanation || Easy approach
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1) We have to check for
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1) We have to check for opening bracket into the string, if we find that we will push that into the stack \n2) In case of closing bracket if we find corresponding opening bracket then we will pop opening bracket from the stack \n3) If the stack is empty then we just count how many idle brackets are left and add then we will add it with the size of stack to get the number of idle brackets to make it valid \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minAddToMakeValid(string s) {\n     stack<char> s1;\n     int c =0;\n     for(int i=0;i<s.size();i++){\n         if(s[i] == \'(\') {\n               s1.push(s[i]);\n         }\n         else {\n             if(s1.empty() == false){\n                s1.pop();\n                \n             }\n             else c++ ;\n         }\n     }\n    \n     return c+s1.size();\n        \n    }\n};\n```\n# **PLEASE UPVOTE IF YOU LIKE MY APPROACH **
['C++']