Easiest Explanation || C++ ||  One  pass || T(n)
@Iemprashant \uD83D\uDE80\n1963. Minimum Number of Swaps to Make the String Balanced\n\n1. C++ Code. \uD83C\uDF93\n2. Please Upvote if it helps\u2B06\uFE0F\n3. 
[**@Iemprashant**](https://leetcode.com/iemprashant/) \uD83D\uDE80\n[1963. Minimum Number of Swaps to Make the String Balanced](https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced/)\n```\n1. C++ Code. \uD83C\uDF93\n2. Please Upvote if it helps\u2B06\uFE0F\n3. Detailed Approach \u2705\n4. Github Repository for code:->\n\n```\n\u26A1[ GithubRepo](https://github.com/iemprashant/LeetHub)\n \n\n**Approach** \uD83D\uDEA9 \n**1-Observation is that we will calculate the open brackets available which are unpaired**\n**2-Now As we have n  open unpaired brackets so there will be n close unpaired brakects ( as both are n/2 in string)**\n**3:- if we settle one pair of open and close brackets by swaping it results in settling 2 pairs**\n```\nExample :-  ] ] [ [ \nso we have 2 open brackets , so we can say we have 2 pair of  unsettled brackets.\n now , if we settle on  bracket     [ ] [ ]  (we swaped first and last), it resutled in settling 2 pairs.\n```\n**4:- so for we need 1 swap for 2 unsettled pairs , for even we need n/2 and for odd we need n/2+1**\n**5:- Basically we need to calculate ceil(open/2)**\n**6:- Take Open count as double as we need decimals values to calculate ceil**\n\n**CODE** \uD83D\uDCCB\n\n```\nclass Solution\n{\n    public:\n        int minSwaps(string str)\n        {\n            double open=0;\n            for(auto s:str){\n                if(s==\'[\'){\n                    open++;\n                }\n                else{\n                    if(open){\n                        open--;\n                    }\n                }\n            }\n            return ceil(open/2);\n        }\n};\n```\n\nPlease Upvote if it helps\u2B06\uFE0F
['String', 'Greedy']