leetcode

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

commit fc65f7171f2500b65ed613e29ccdb7c511a15275
parent a5cd13cc92be06b5820dde677f39411665c3c6a9
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Tue, 6 Aug 2024 19:25:26 +0200

1 Random Problem

Diffstat:
A Problems/1262.cpp | ++++++++++++++
M README.md | +

2 files changed, 15 insertions(+), 0 deletions(-)


diff --git a/ Problems/1262.cpp b/ Problems/1262.cpp

@@ -0,0 +1,14 @@
class Solution {
public:
int maxSumDivThree(const vector<int> &nums) const {
vector<int> dp(3, 0);
for (const int n : nums) {
for (const int m : vector<int>(dp)) {
dp[(m + n) % 3] = max(dp[(m + n) % 3], m + n);
}
}
return dp[0];
}
};

diff --git a/ README.md b/ README.md

@@ -727,6 +727,7 @@ for solving problems. | 1254 | Medium | [Number of Closed Islands](Problems/1254.cpp) | | 1255 | Hard | [Maximum Score Words Formed by Letters](Problems/1255.cpp) | | 1261 | Medium | [Find Elements in a Contaminated Binary Tree](Problems/1261.cpp) |
| 1262 | Medium | [Greatest Sum Divisible by Three](Problems/1262.cpp) |
| 1266 | Easy | [Minimum Time Visiting All Points](Problems/1266.cpp) | | 1267 | Medium | [Count Servers that Communicate](Problems/1267.cpp) | | 1268 | Medium | [Search Suggestions System](Problems/1268.cpp) |