C++|4 lines code | without stack and swap | O(n), O(1)-98.88%beats 🔥
Intuition\nFirst remove already balenced brackets and after that cnt ans for rest brackets \n\n# Approach\n See some below problems and observing the ans \n"][]
# Intuition\nFirst remove already balenced brackets and after that cnt ans for rest brackets \n\n# Approach\n See some below problems and observing the ans \n"][][" after remove -->> "]["  ans = 1 \n"]][["  ans = 1  bcoz in one swap "[][]" it will be balence, here num of unbalenced pair is 2, which is even so 2/2 ==1\n"]]][[[" --->>    "[][][]" after swap innermost  and outermost pair ,  here num of unbalenced pair is 3 which is odd so 3/2 ==1 + 3%2==1 ->> 1+1 ==2 \n\n# Complexity\n- Time complexity:\n- O(n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n# O(1) 98.88% beats \uD83D\uDD25\n\n# Code\n```\nclass Solution {\npublic:\n    int minSwaps(string s) {\n        int left=0,right=0; \n        for(auto c:s){\n            if(c==\'[\')right++;   // requirement of right \']\' parentheses\n            else if(right>0)right--;  //if right req exist and we got right, so we decrement right req it make valid "[]"\n            else left++;      // left " [ " req \n        }\n        return left/2  + left%2;   // as in the given problem it is given left ==right and also equals to number of unbalenced pair \n    }\n};\n#<!-- If u like plz upvote !! -->\n\n```
['Math', 'String', 'Stack', 'Greedy', 'C++']