leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit 31e83554ca6ab0ae5cf1c5ea3dd71dd97759ad85
parent ff457c055a4581529630fda689766f915900843f
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Tue, 17 Jan 2023 13:33:37 +0100

Daily Problem

Diffstat:
AProblems/0926.cpp | 12++++++++++++
MREADME.md | 1+
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Problems/0926.cpp b/Problems/0926.cpp @@ -0,0 +1,12 @@ +class Solution { +public: + int minFlipsMonoIncr(string s) { + int res = 0, num = 0; + for (char c : s) + if (c == '0') + res = min(num, res + 1); + else + ++num; + return res; + } +}; diff --git a/README.md b/README.md @@ -206,6 +206,7 @@ for solving problems. | 0897 | Easy | [Increasing Order Search Tree](Problems/0897.cpp) | | 0901 | Medium | [Online Stock Span](Problems/0901.cpp) | | 0905 | Easy | [Sort Array By Parity](Problems/0905.cpp) | +| 0926 | Medium | [Flip String to Monotone Increasing](Problems/0926.cpp) | | 0931 | Medium | [Minimum Falling Path Sum](Problems/0931.cpp) | | 0933 | Easy | [Number of Recent Calls](Problems/0933.cpp) | | 0938 | Easy | [Range Sum of BST](Problems/0938.cpp) |