From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/flip_string_monotone_increase.cpp | 36 --------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 other/flip_string_monotone_increase.cpp (limited to 'other/flip_string_monotone_increase.cpp') diff --git a/other/flip_string_monotone_increase.cpp b/other/flip_string_monotone_increase.cpp deleted file mode 100644 index 35e0e0c..0000000 --- a/other/flip_string_monotone_increase.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "leetcode.h" - -/* - * a binary string is monotone increasing if it consists of some number - * of 0's (none is valid), followed by some number of 1's (none is valid) - * given: binary string 's'. you can flip 's[i]' changing for 0 to 1 or vice - * versa. return the minimum number of flips to make 's' monotone increasing. - */ - -class Solution { -public: - int minFlipsMonoIncr(string s) { - int flips = 0, cnt = 0; - for (auto i : s) { - if (i == '1') - cnt++; - else - flips++; - flips = min(flips, cnt); - } - return flips; - } -}; - -int main() { - Solution obj; - cout << obj.minFlipsMonoIncr("00110") << endl; - // expect: 1 - // flip last digit to get 00111 - cout << obj.minFlipsMonoIncr("010110") << endl; - // expect: 2 - // flip s[1] s[5] to get 000111 - cout << obj.minFlipsMonoIncr("00011000") << endl; - // expect: 2 - // flip s[3] s[4] to get 00000000 -} -- cgit v1.2.3