In One loop (2 Pointer) C++ || Java || Python
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1. Initialize a count c
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize a count ***cnt*** and ***ans*** which will store our answer.\n2. Interate into string if you **find \'0\'**\n3. Then take the distance from index 0 (it will be the index i at which you find \'0\') \n3. Then **add this distance to our ans and subtract cnt** which is the number of \'0\'s which  you  already arranged. \nSame time increase cnt by 1.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n# If you find helpful Please UP VOTE \n\n#  C++\n```\nclass Solution {\npublic:\n    long long minimumSteps(string s) {\n        int n = s.size();\n        int cnt = 0;\n        long long ans = 0;\n        for(int i = 0; i < n; i++){\n            if(s[i] == \'0\'){\n                ans += i - cnt;\n                cnt++;\n            }\n        }\n        \n        return ans;\n    }\n};\n```\n**Java**\n\n```\nclass Solution {\n    public long minimumSteps(String s) {\n        int n = s.length();\n        int cnt = 0;\n        long ans = 0;\n        \n        for (int i = 0; i < n; i++) {\n            if (s.charAt(i) == \'0\') {\n                ans += i - cnt;\n                cnt++;\n            }\n        }\n        \n        return ans;\n    }\n}\n\n```\n**Python**\n```\nclass Solution:\n    def minimumSteps(self, s):\n        n = len(s)\n        cnt = 0\n        ans = 0\n        \n        for i in range(n):\n            if s[i] == \'0\':\n                ans += i - cnt\n                cnt += 1\n        \n        return ans\n\n\n
['Two Pointers', 'String', 'Python', 'C++', 'Java']