Very Easy Java Solution 💯 || Beats 100% 🚀 || O(n) Time Complexity
Intuition\n Describe your first thoughts on how to solve this problem. \nTraverse the string from left to right and count number of \'1\'. As soon as the we get
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTraverse the string from left to right and count number of \'1\'. As soon as the we get a \'0\' we increament the count of swap operations to the count of \'1\'.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nTraverse the given string and track the count of 1s in a variable count1.\nIncrement the value of count1 for every occurance of \'1\'. If we get a \'0\' while traversing the string then we should increment the add the count of 1s (count1) to our answer variable.\n\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        int n = s.length();\n\n        long operations = 0;\n        long count1 = 0;\n\n        int i = 0;\n        while(i<n) {\n            if(s.charAt(i) == \'1\') {\n                count1++;\n            } else {\n                operations += count1;\n            }\n            i++;\n        }\n\n        return operations;\n    }\n}\n```
['String', 'Java']