leetcode

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

2396.cpp (531B)


0 class Solution { 1 public: 2 bool isStrictlyPalindromic(int n) { return false; } 3 }; 4 5 class Solution { 6 public: 7 bool isStrictlyPalindromic(int n) { 8 string s = ""; 9 for (int base = n - 2, crnt = n; base >= 2; base--, crnt = n) { 10 s.clear(); 11 do { 12 s += '0' + crnt % base; 13 } while ((crnt /= base) > 0); 14 int i = 0, j = s.size() - 1; 15 while (i < j) 16 if (s[i++] != s[j--]) return false; 17 } 18 19 return true; 20 } 21 };