Minimize Steps by Counting Ones from the Right | Java | C++ | Video Solution
Intuition, approach, and complexity discussed in video solution in detail.\nhttps://youtu.be/F04MvLW7hT8\n# Code\njava []\nclass Solution {\n    public long min
# Intuition, approach, and complexity discussed in video solution in detail.\nhttps://youtu.be/F04MvLW7hT8\n# Code\n``` java []\nclass Solution {\n    public long minimumSteps(String s) {\n        int size = s.length();\n        long steps = 0l;\n        int sumFrmRight = 0;\n        for(int indx = size - 1; indx > -1; indx--){\n            char chr = s.charAt(indx);\n            if(chr == \'1\'){\n                steps += size - 1 - indx - sumFrmRight;\n            }\n            sumFrmRight += (int)(chr - \'0\');\n        }\n        return steps;\n    }\n}\n```\n```cpp []\nclass Solution {\npublic:\n    long long minimumSteps(string s) {\n        int size = s.size();\n        long long steps = 0ll;\n        int sumFrmRight = 0;\n        for(int indx = size - 1; indx > -1; indx--){\n            char chr = s[indx];\n            if(chr == \'1\'){\n                steps += size - 1 - indx - sumFrmRight;\n            }\n            sumFrmRight += (int)(chr - \'0\');\n        }\n        return steps;\n    }\n};\n```
['String', 'Greedy', 'C++', 'Java']