Easy Python3 solution, O(n)
\n\n# Code\npython3 []\nclass Solution:\n    def minSwaps(self, s: str) -> int:\n        open = 0\n        ans = 0\n        for i in s:\n            if i == \'[
\n\n# Code\n```python3 []\nclass Solution:\n    def minSwaps(self, s: str) -> int:\n        open = 0\n        ans = 0\n        for i in s:\n            if i == \'[\':\n                open += 1\n            else:\n                if open > 0:\n                    open -= 1\n                else:\n                    ans += 1\n                    open += 1\n        return ans\n            \n        \n```
['Python3']