leetcode

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

commit fa7e9d420360df60e4e7e2d89d9302d4dbb67e3f
parent 1c2c815cfdd4dbd451dd2972974db99e628c2c6e
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Thu,  5 Sep 2024 21:15:23 +0200

Daily Problem

Diffstat:
AProblems/2028.cpp | 17+++++++++++++++++
MREADME.md | 1+
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/Problems/2028.cpp b/Problems/2028.cpp @@ -0,0 +1,17 @@ +class Solution { + public: + vector<int> missingRolls(const vector<int> &rolls, int mean, int n) const { + int sum = mean * (n + size(rolls)); + int left = sum - accumulate(begin(rolls), end(rolls), 0); + + if (left < n || n * 6 < left) return {}; + + vector<int> res(n, left / n); + + for (int i = 0; i < left % n; i++) { + res[i]++; + } + + return res; + } +}; diff --git a/README.md b/README.md @@ -1067,6 +1067,7 @@ for solving problems. | 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) | +| 2028 | Medium | [Find Missing Observations](Problems/2028.cpp) | | 2033 | Medium | [Minimum Operations to Make a Uni-Value Grid](Problems/2033.cpp) | | 2037 | Easy | [Minimum Number of Moves to Seat Everyone](Problems/2037.cpp) | | 2038 | Medium | [Remove Colored Pieces if Both Neighbors are the Same Color](Problems/2038.cpp) |