leetcode

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

2249.cpp (666B)


      1 class Solution {
      2   public:
      3     int countLatticePoints(vector<vector<int>> &circles) {
      4         unordered_set<int> us;
      5 
      6         for (const auto &circle : circles) {
      7             for (int i = circle[0] - circle[2]; i <= circle[0] + circle[2]; i++) {
      8                 for (int j = circle[1] - circle[2]; j <= circle[1] + circle[2]; j++) {
      9                     const int a = (i - circle[0]) * (i - circle[0]);
     10                     const int b = (j - circle[1]) * (j - circle[1]);
     11                     const int c = circle[2] * circle[2];
     12 
     13                     if (a + b <= c) us.insert(i * 200 + j);
     14                 }
     15             }
     16         }
     17 
     18         return size(us);
     19     }
     20 };