C++ || Easy approach
\nclass Solution {\npublic:\n    int minSwaps(string s) {\n        int n = s.size(), open = 0, closed = 0, p = n-1, ans = 0;\n        for(int i=0; i<n; ++i) {\n
```\nclass Solution {\npublic:\n    int minSwaps(string s) {\n        int n = s.size(), open = 0, closed = 0, p = n-1, ans = 0;\n        for(int i=0; i<n; ++i) {\n            (s[i] == \'[\') ? open++ : closed++;\n            if(closed > open) {\n                while(s[p] != \'[\') p--;\n                swap(s[p], s[i]);\n                ans++;\n                closed--;\n                open++;\n            }\n        }\n        return ans;\n    }\n};\n```
[]