C++ || easy solution using stack
We will use a stack \nif we find any balanced pair we will pop both.\nat last we will get a unbalanced string .\n\nObservation for min swaps:\nif we consider th
We will use a stack \nif we find any balanced pair we will pop both.\nat last we will get a unbalanced string .\n\nObservation for min swaps:\nif we consider that we have 3 unbalanced pair and 4 unbalanced pair then we need only 2 swaps.\nas for 4 it will be just 2 swaps and it will become balanced.\nbut in 3 it will take 1 swap for even pair and for the last one more will be required.\n\n```\nclass Solution {\npublic:\n    int minSwaps(string s) {\n\n        stack<char> st;\n        st.push(s[0]);\n        for(int i=1;i<s.size();i++)\n        {\n            if(!st.empty() && st.top()==\'[\' && s[i]==\']\')\n                st.pop();\n            else st.push(s[i]);\n        }\n    \n        int t=st.size()/2;\n        if(t%2==0)\n            return t/2;\n        return (t+1)/2;\n    }\n};\n```
['Stack', 'C']