leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2442.cpp (418B)
0 class Solution {
1 public:
2 int countDistinctIntegers(const vector<int> &nums) {
3 unordered_set<int> us(nums.begin(), nums.end());
4 for (int n : nums) {
5 int rev = 0;
6 while (n % 10 == 0)
7 n /= 10;
8 do
9 rev = (rev * 10) + n % 10;
10 while ((n /= 10) > 0);
11 us.insert(rev);
12 }
13 return us.size();
14 }
15 };