leetcode

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

commit cefb0ade590b17bae2190495e58429b77950d84a
parent d8faf52829a7587344fa53464d9938ab3fc423cf
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Thu, 10 Oct 2024 12:35:35 +0200

1 Random Problem

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

diff --git a/Problems/1033.cpp b/Problems/1033.cpp @@ -0,0 +1,11 @@ +class Solution { + public: + vector<int> numMovesStones(int a, int b, int c) const { + if (a > b) swap(a, b); + if (a > c) swap(a, c); + if (b > c) swap(b, c); + + if (a + 1 == b && b + 1 == c) return {0, 0}; + return {b - a <= 2 || c - b <= 2 ? 1 : 2, c - a - 2}; + } +}; diff --git a/README.md b/README.md @@ -657,6 +657,7 @@ for solving problems. | 1027 | Medium | [Longest Arithmetic Subsequence](Problems/1027.cpp) | | 1029 | Medium | [Two City Scheduling](Problems/1029.cpp) | | 1031 | Medium | [Maximum Sum of Two Non-Overlapping Subarrays](Problems/1031.cpp) | +| 1033 | Medium | [Moving Stones Until Consecutive](Problems/1033.cpp) | | 1035 | Medium | [Uncrossed Lines](Problems/1035.cpp) | | 1038 | Medium | [Binary Search Tree to Greater Sum Tree](Problems/1038.cpp) | | 1039 | Medium | [Minimum Score Triangulation of Polygon](Problems/1039.cpp) |