[JavaScript] find the patterns then it's easy
Analysis:\nFind the rules:\ntext\n1 mismatch: ][][  --> 1 swap\n2 mismatch: ]][[  --> 1 swap\n3 mismatch: ]]][[[  --> 2 swap\n4 mismatch: ]]]][[[[  --> 2 swap\n
**Analysis:**\nFind the rules:\n```text\n1 mismatch: ][][  --> 1 swap\n2 mismatch: ]][[  --> 1 swap\n3 mismatch: ]]][[[  --> 2 swap\n4 mismatch: ]]]][[[[  --> 2 swap\n5 mismatch: ]]]]][[[[[  --> 3 swap\n...\n```\n**Steps:**\n- find the "max" mismatch count\n- return the `Math.ceil(max_mismatch_count / 2)`\n\n**JavaScript:** \n```js\nvar minSwaps = function(s) {\n    var mismatch  = 0;\n    var cnt = 0;\n    for(var i=0; i<s.length; i++)\n    {\n        if(s[i] === \']\')\n        {\n            cnt--;\n        }\n        else\n        {\n             cnt++;\n        }\n        if(cnt < 0)\n        {\n            mismatch = Math.min(mismatch, cnt);\n        }\n    }\n    return  Math.ceil(-mismatch/ 2);\n};\n```
['JavaScript']