Count Number of Distinct Integers After Reverse Operations
You are given an array nums consisting of positive integers.
You have to take each integer in the array, reverse its digits, and add it to the end of the array. You should apply this operation to the original integers in nums.
Return the number of distinct integers in the final array.
Example 1
Input
nums = [1,13,10,12,31]Output
6After including each reversed number, the final array contains the distinct integers 1, 10, 12, 13, 21, and 31.
Example 2
Input
nums = [2,2,2]Output
1Reversing every 2 still gives 2, so the final array contains only one distinct integer.
Constraints
- 1 <= nums.length <= 10^5
- 1 <= nums[i] <= 10^6