LeetCode-Solutions-in-Cpp17

Solutions to high-frequency interview questions of LeetCode in C++17, taking into account both efficiency and comprehensibility.


Project maintained by downdemo Hosted on GitHub Pages — Theme by mattgraham
class Solution {
 public:
  bool isPowerOfThree(int n) {
    int t = pow(3, static_cast<int>(log(INT_MAX) / log(3)));
    return n > 0 && t % n == 0;
  }
};
class Solution {
 public:
  bool isPowerOfThree(int n) { return n > 0 && 1162261467 % n == 0; }
};