Simple O(N) solution - beats 99.87% of the solution
Intuition\n Describe your first thoughts on how to solve this problem. \nFor every 1, we will need to do swaps equal to the number of 0 on it\'s right. \n So st
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFor every `1`, we will need to do swaps equal to the number of `0` on it\'s right. \n* So start from the right and keep track of number of `0` seen so far. \n* For every `1` seen, add the number of `0` seen so far to the answer. \n\n##### Please upvote if you like the solution\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public long minimumSteps(String s) {\n        long ans = 0; \n        int zeroSeenSoFar = 0; \n        char[] sArr = s.toCharArray();\n        for(int i=sArr.length-1; i>=0; i--){\n            if(sArr[i]==\'1\'){\n                ans = ans + zeroSeenSoFar;\n            } else {\n                zeroSeenSoFar++;\n            }\n        }\n        return ans; \n    }\n}\n```
['Java']