leetcode

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

1362.cpp (296B)


      1 class Solution {
      2   public:
      3     vector<int> closestDivisors(const int num) const {
      4         for (int i = sqrt(num + 2); i > 0; i--) {
      5             if ((num + 1) % i == 0) return {i, (num + 1) / i};
      6             if ((num + 2) % i == 0) return {i, (num + 2) / i};
      7         }
      8         return {};
      9     }
     10 };