Java Solution Simple
Code\njava-WITH-SPACE []\nclass Solution {\n    public int minSwaps(String s) {\n\n        Stack<Character> stack = new Stack<>();\n        int countSwap = 0;\n
# Code\n```java-WITH-SPACE []\nclass Solution {\n    public int minSwaps(String s) {\n\n        Stack<Character> stack = new Stack<>();\n        int countSwap = 0;\n\n        for(char ch:s.toCharArray()){\n            if(ch==\'[\'){\n                stack.push(ch);\n            } else{\n                if(!stack.isEmpty()){\n                    stack.pop();\n                } else{\n                    countSwap++;\n                }\n            }\n        }\n\n        return (countSwap+1)/2;\n    }\n}\n```\n``` JAVA-WITHOUT-SPACE []\nclass Solution {\n    public int minSwaps(String s) {\n// WithOut using Extra Space.....\n        int countSwap=0;\n        for(char ch:s.toCharArray()){\n            if(ch==\'[\'){\n                countSwap++;\n            }\n            else if(countSwap>0){\n                countSwap--;\n            }\n        }        \n        return (countSwap+1)/2;\n    }\n}\n```
['Math', 'Two Pointers', 'String', 'Stack', 'Greedy', 'Java']