leetcode

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

commitcefb0ade590b17bae2190495e58429b77950d84a
parentd8faf52829a7587344fa53464d9938ab3fc423cf
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateThu, 10 Oct 2024 10:35:35 +0200

1 Random Problem

Diffstat:
AProblems/1033.cpp|+++++++++++
MREADME.md|+

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) |