2938.cpp (294B)
1 class Solution { 2 public: 3 long long minimumSteps(const string &s) const { 4 long long res = 0; 5 6 for (int i = 0, cnt = 0; i < size(s); i++) { 7 if (s[i] & 1) 8 cnt++; 9 else 10 res += cnt; 11 } 12 13 return res; 14 } 15 };