Python Easy to Understand
Intuition\n\nWe need to minimize the total number of moves to bring all \'0\'s to the front of the string, without changing the relative order of the \'0\'s. Ea
# Intuition\n\nWe need to minimize the total number of moves to bring all \'0\'s to the front of the string, without changing the relative order of the \'0\'s. Each move can be considered as shifting a \'0\' left in the string. The goal is to count the minimum steps required to do so.\n\n# Approach\n\n## Identify \'0\' positions:\n\nTraverse the string and store the indices of all \'0\'s in a list (zero_indices).\n\n## Calculate steps:\n\n- For each \'0\', compute how many steps it takes to move it to its correct position (i.e., based on how many \'0\'s have already been moved). The steps required for each \'0\' are the difference between its current index and its target position (which is tracked by zero_counter).\n- Accumulate these steps in res and increment zero_counter after each move.\n\n## Return result:\n\nThe final value of res is the minimum number of steps needed to shift all \'0\'s to the front while maintaining their order.\n\n# Complexity\n- Time complexity: O(n) - where n is the length of the string\n\n- Space complexity: O(number_of_zeros)\n\n# Code\n```python3 []\nclass Solution:\n    def minimumSteps(self, s: str) -> int:\n        zero_indices = []\n\n        for i in range(len(s)):\n            if s[i] == \'0\':\n                zero_indices.append(i)\n        \n        zero_counter = 0\n        res = 0\n        for ind in zero_indices:\n            res += ind - zero_counter\n            zero_counter += 1\n        \n        return res
['String', 'Python', 'Python3']