leetcode

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

2442.cpp (418B)


      1 class Solution {
      2   public:
      3     int countDistinctIntegers(const vector<int> &nums) {
      4         unordered_set<int> us(nums.begin(), nums.end());
      5         for (int n : nums) {
      6             int rev = 0;
      7             while (n % 10 == 0)
      8                 n /= 10;
      9             do
     10                 rev = (rev * 10) + n % 10;
     11             while ((n /= 10) > 0);
     12             us.insert(rev);
     13         }
     14         return us.size();
     15     }
     16 };