Beats 100%, clean code, easy to understand, beginner friendly
Intuition\n Describe your first thoughts on how to solve this problem. \nwe have to shift all the 1\'s to the end of string\n# Approach\n Describe your approach
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nwe have to shift all the 1\'s to the end of string\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1) define two variables answer and whiteballindex\n2) Start traversing the string from right till the string is traversed completly.\n3) make a variable whiteballindex to store the required position of white ball i.e. last index (length - 1),\n4) if the character at that index is \'1\' subtract the index of occurence of \'1\' i.e. i from whiteballindex i.e. the number of swaps to shift \'1\' to required position and add it to answer\n5) now decrease the whiteballindex by one (new required index of 1);\n6) return the answer.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```java []\nclass Solution {\n    public long minimumSteps(String s) {\n        long answer = 0;\n        int len = s.length();\n        int whiteballindex = len-1;        \n        for(int i = len -1; i>=0; --i)\n        {\n            char c = s.charAt(i);\n            if(c == \'1\')\n            {\n                answer += whiteballindex - i;\n                whiteballindex--;\n            }\n        }\n        return answer;\n    }\n}\n```
['Java']