diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/flip_string_monotone_increase.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/flip_string_monotone_increase.cpp')
-rw-r--r-- | other/flip_string_monotone_increase.cpp | 36 |
1 files changed, 0 insertions, 36 deletions
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 -} |