leetcode

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

commit 3fed476d3c5decfc742040e818812c54fab4ce57
parent 2714655c4c0d7d17f4324320836901b51f1ebfe8
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sun,  1 Sep 2024 12:43:37 +0200

Daily Problem

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

diff --git a/Problems/2022.cpp b/Problems/2022.cpp @@ -0,0 +1,13 @@ +class Solution { + public: + vector<vector<int>> construct2DArray(const vector<int> &original, int n, int m) const { + vector<vector<int>> res(n); + + if (m * n != size(original)) return {}; + for (int i = 0, k = 0; i < n; ++i) { + res[i] = vector(begin(original) + i * m, begin(original) + (i + 1) * m); + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1061,6 +1061,7 @@ for solving problems. | 2002 | Medium | [Maximum Product of the Length of Two Palindromic Subsequences](Problems/2002.cpp) | | 2009 | Hard | [Minimum Number of Operations to Make Array Continuous](Problems/2009.cpp) | | 2013 | Medium | [Detect Squares](Problems/2013.cpp) | +| 2022 | Easy | [Convert 1D Array Into 2D Array](Problems/2022.cpp) | | 2023 | Medium | [Number of Pairs of Strings With Concatenation Equal to Target](Problems/2023.cpp) | | 2024 | Medium | [Maximize the Confusion of an Exam](Problems/2024.cpp) | | 2033 | Medium | [Minimum Operations to Make a Uni-Value Grid](Problems/2033.cpp) |