leetcode

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

commit 048e32ebbf9cfca391f060f5b5582b40f226f336
parent fc43600dad3d0c31852434baad1426bf8b9eaa12
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon, 25 Dec 2023 21:10:42 +0000

1 Random Problem

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

diff --git a/Problems/0769.cpp b/Problems/0769.cpp @@ -0,0 +1,12 @@ +class Solution { + public: + int maxChunksToSorted(const vector<int> &arr) const { + set<int> st; + int res = 0; + for (int i = 0; i < arr.size(); i++) { + st.insert(arr[i]); + if (*st.rbegin() == i) res++; + } + return res; + } +}; diff --git a/README.md b/README.md @@ -443,6 +443,7 @@ for solving problems. | 0752 | Medium | [Open the Lock](Problems/0752.cpp) | | 0763 | Medium | [Partition Labels](Problems/0763.cpp) | | 0767 | Medium | [Reorganize String](Problems/0767.cpp) | +| 0769 | Medium | [Max Chunks To Make Sorted](Problems/0769.cpp) | | 0779 | Medium | [K-th Symbol in Grammar](Problems/0779.cpp) | | 0783 | Easy | [Minimum Distance Between BST Nodes](Problems/0783.cpp) | | 0784 | Medium | [Letter Case Permutation](Problems/0784.cpp) |