commit 4028c7c448da955a7cf3cd52d316deecc72a1a73 parent fa7e9d420360df60e4e7e2d89d9302d4dbb67e3f Author: Dimitrije Dobrota <mail@dimitrijedobrota.com> Date: Fri, 6 Sep 2024 13:03:10 +0200 1 Random Problem Diffstat:
A | Problems/2249.cpp | | | 20 | ++++++++++++++++++++ |
M | README.md | | | 1 | + |
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/Problems/2249.cpp b/Problems/2249.cpp @@ -0,0 +1,20 @@ +class Solution { + public: + int countLatticePoints(vector<vector<int>> &circles) { + unordered_set<int> us; + + for (const auto &circle : circles) { + for (int i = circle[0] - circle[2]; i <= circle[0] + circle[2]; i++) { + for (int j = circle[1] - circle[2]; j <= circle[1] + circle[2]; j++) { + const int a = (i - circle[0]) * (i - circle[0]); + const int b = (j - circle[1]) * (j - circle[1]); + const int c = circle[2] * circle[2]; + + if (a + b <= c) us.insert(i * 200 + j); + } + } + } + + return size(us); + } +}; diff --git a/README.md b/README.md @@ -1135,6 +1135,7 @@ for solving problems. | 2243 | Easy | [Calculate Digit Sum of a String](Problems/2243.cpp) | | 2244 | Medium | [Minimum Rounds to Complete All Tasks](Problems/2244.cpp) | | 2246 | Hard | [Longest Path With Different Adjacent Characters](Problems/2246.cpp) | +| 2249 | Medium | [Count Lattice Points Inside a Circle](Problems/2249.cpp) | | 2251 | Hard | [Number of Flowers in Full Bloom](Problems/2251.cpp) | | 2257 | Medium | [Count Unguarded Cells in the Grid](Problems/2257.cpp) | | 2260 | Medium | [Minimum Consecutive Cards to Pick Up](Problems/2260.cpp) |