Skip to content

Commit

Permalink
added Count Number Distinct Integer Rev Ops probl
Browse files Browse the repository at this point in the history
  • Loading branch information
mukul96 authored Dec 4, 2022
1 parent 75bafc2 commit 075af50
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution {
public:
int reverseNumber(int number){
int currNumber = 0;
while(number!=0){
currNumber = currNumber*10 + (number%10);
number = number/10;
}
return currNumber;
}
int countDistinctIntegers(vector<int>& nums) {
unordered_map<int,int> mp;
for(int i=0;i<nums.size();i++){
mp[nums[i]] = 1;
int reverseNum = reverseNumber(nums[i]);
mp[reverseNum] = 1;
}

return mp.size();

}
};

0 comments on commit 075af50

Please sign in to comment.