🚀🚀🚀 SUPER SIMPLE & EFFICIENT 💯💯💯
\n# Intuition\nProblem asks number of required swaps to fold all 1s on the right side of string s. To do so, we need to iterate through the string s from right 
![image.png](https://assets.leetcode.com/users/images/5c650759-aa8d-48a5-87dc-5c3c7189f2f6_1728957064.9609766.png)\n# Intuition\nProblem asks number of required swaps to fold all `1`s on the right side of string `s`. To do so, we need to iterate through the string `s` from right to left.\n> Note that we can only move `1` on `s[i]` to `s[i+1]`, not `s[i+2,3...]`\n\n\n\n# Approach\nTo get number of swaps for every single `1` we need to count zeros and store the value on `zero_cnt` variable and when we encounter `1` we must add up value on `zero_cnt` to the `ans`.\n\n# Step by step\n1. Initialize `ans` and `zero_cnt` to 0.\n2. iterate through the string `s` from right to left with `for` loop.\n3. If `0` is encountered, increment `zero_cnt` to 1.\n4. if `1` is encountered, add up `zero_cnt` to `ans`\n5. After `for` end, return the `ans`. \n\n# Complexity\n- Time complexity :  **O(n)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    Because we walked through one time.\n\n- Space complexity : **O(1)**\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    Because we used only two variables.\n# Code\n```python3 []\nclass Solution:\n    def minimumSteps(self, s: str) -> int:\n        ans = zero_cnt = 0 \n        for i in s[::-1]:\n            if i == "0":\n                zero += 1\n            elif i == \'1\':\n                ans += zero  \n        return ans  \n        \n```\n```C++ []\nclass Solution {\npublic:\n    long long minimumSteps(std::string s) {\n        long long ans = 0;  // Change to long long\n        int zero_cnt = 0;\n\n        // Traverse the string in reverse\n        for (int i = s.size() - 1; i >= 0; --i) {\n            if (s[i] == \'0\') {\n                zero_cnt++;  // Count zeros\n            } else if (s[i] == \'1\') {\n                ans += zero_cnt;  // Add to ans the count of zeros encountered\n            }\n        }\n\n        return ans;  // Return the final count\n    }\n};\n```\n```C# []\npublic class Solution {\n    public long MinimumSteps(string s) {\n        long ans = 0;\n        long zeroCount = 0;\n        \n        // Loop through the string in reverse order\n        for (int i = s.Length - 1; i >= 0; i--) {\n            if (s[i] == \'0\') {\n                zeroCount++;\n            } else if (s[i] == \'1\') {\n                ans += zeroCount;\n            }\n        }\n        \n        return ans;\n    }\n}\n\n        \n```\n\n```Java []\nclass Solution {\n    public long minimumSteps(String s) {\n        long ans = 0;\n        long zeroCnt = 0;\n\n        // Looping through the string in reverse order\n        for (int i = s.length() - 1; i >= 0; i--) {\n            char ch = s.charAt(i);  // Getting the character at position i\n            if (ch == \'0\') {\n                zeroCnt++;\n            } else if (ch == \'1\') {\n                ans += zeroCnt;\n            }\n        }\n        return ans;\n    }\n}\n\n```\n```Go []\nfunc minimumSteps(s string) int64 {\n    var ans, zeroCnt int64\n    for i := len(s) - 1; i >= 0; i-- {\n        if s[i] == \'0\' {\n            zeroCnt++\n        } else if s[i] == \'1\' {\n            ans += zeroCnt\n        }\n    }\n    return ans\n}\n```\n```JavaScript []\n/**\n * @param {string} s\n * @return {number}\n */\nvar minimumSteps = function(s) {\n    let ans = 0;\n    let zeroCnt = 0;\n    for (let i = s.length - 1; i >= 0; i--) {\n        if (s[i] === "0") {\n            zeroCnt += 1;\n        } else if (s[i] === "1") {\n            ans += zeroCnt;\n        }\n    }\n    return ans;\n};\n\n```\n
['String', 'Greedy', 'C++', 'Java', 'Go', 'Python3', 'JavaScript']