leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE | |
commit | 2e052050a026f65c089fd2c5f7207b4eb0b5bde0 |
parent | a3f44daa25c2a8d48b64738c65a728082d91448e |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Sun, 17 Mar 2024 19:38:39 +0000 |
1 Random Problem
Diffstat:A | Problems/1010.cpp | | | ++++++++++++++++ |
M | README.md | | | + |
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Problems/1010.cpp b/Problems/1010.cpp
@@ -0,0 +1,16 @@
class Solution {
public:
int numPairsDivisibleBy60(const vector<int> &time) const {
static int count[60];
int res = 0;
memset(count, 0x00, sizeof(count));
for (const int n : time) {
const int rem = n % 60;
res += rem == 0 ? count[0] : count[60 - rem];
count[rem]++;
}
return res;
}
};
diff --git a/README.md b/README.md
@@ -584,6 +584,7 @@ for solving problems.
| 1004 | Medium | [Max Consecutive Ones III](Problems/1004.cpp) |
| 1006 | Medium | [Clumsy Factorial](Problems/1006.cpp) |
| 1008 | Medium | [Construct Binary Search Tree from Preorder Traversal](Problems/1008.cpp) |
| 1010 | Medium | [Pairs of Songs With Total Durations Divisible by 60](Problems/1010.cpp) |
| 1011 | Medium | [Capacity To Ship Packages Within D Days](Problems/1011.cpp) |
| 1014 | Medium | [Best Sightseeing Pair](Problems/1014.cpp) |
| 1016 | Medium | [Binary String With Substrings Representing 1 To N](Problems/1016.cpp) |