Simple approach Beats 100% users
Intuition\nWhenever \'0\' is encountered, mininum number of swaps required to move this \'0\' to front is number of ones present from 0th index to this zero. Af
# Intuition\nWhenever \'0\' is encountered, mininum number of swaps required to move this \'0\' to front is number of ones present from 0th index to this zero. After swapping this zero to forward by swapping with adjacent \'1\'s one by one, The \'1\'s will also be getting sorted till current position.\n\nWhenever you see a second zero, add the number of \'1\'s present from starting index to this zero.\nSame will be applied for next coming zeros also.\n\n# Approach\n1. Take variable to keep track of ones count.\n2. Take variable for storing the minimum number of swaps for each zero.\n3. Iterate through the string and keep incrementing onesCount for every \'1\'. If you see zero, just add the ones count to the answer variable.\n\n# Complexity\n- Time complexity:\nO(N) - N is number of characters in a given string\n\n- Space complexity:\nO(1)\n\n# Code\n```java []\nclass Solution {\n    public long minimumSteps(String s) {\n//for ones count\n        int onesCount=0;\n// for stroing the answer\n        long minSwaps=0;\n        for(char c: s.toCharArray()){\n            if(c==\'1\') onesCount++;\n            else minSwaps+=onesCount;\n        }\n        return minSwaps;\n    }\n}\n```
['Java']