SIMPLE STACK COMMENTED C++ SOLUTION
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:o(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:o(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n\n\nclass Solution {\npublic:\n    int minSwaps(string s) {\n        stack<char> st;\n        for(auto&c : s){\n            if(c == \'[\'){\n                // Push opening brackets onto the stack\n                st.push(c);\n            }else{ // c == \']\'\n                if(!st.empty() && st.top() == \'[\') {\n                    // If there\'s a matching opening bracket on the stack, pop it\n                    st.pop();\n                }else{\n                    // Otherwise, push the closing bracket onto the stack\n                    st.push(c);\n                }\n            }\n        }\n        // The stack now contains unmatched brackets\n        // Half of the stack size (rounded up) will be the number of swaps needed\n        int unmatched = st.size();\n        return (unmatched / 2 + 1) / 2;\n    }\n};\n```
['C++']