Simplest greedy c++ solution explained
Intuition\n Describe your first thoughts on how to solve this problem. \nIt is obvious that the \'0\' at any index should go through all the previous \'1\'s to 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIt is obvious that the \'0\' at any index should go through all the previous \'1\'s to get into the left  most position.\nTherefore **counting the number of \'1\'s before a \'0\' will give the number of steps needed for that \'0\' to go to the left of all the \'1\'s.**\nSo for every \'0\' the ans will be updated with the \'1\'s count before that \'0\'.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nif the current index have \'1\' , then we will be updating the count of one by 1.\nif the current index have \'0\' , then we will be updating the answer with the number of ones it had previously.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    long long minimumSteps(string s) {\n        long long ans=0;\n        int n=s.size();\n        int countofones=0;\n        for(int i=0;i<n;i++){\n            if(s[i]==\'1\')++countofones;\n            else{\n                ans+=countofones;\n            }\n        }\n        return ans;        \n    }\n};\n```
['Greedy', 'C++']