You're given an array nums containing positive integers. Your task is to perform a fascinating transformation: take each integer in the array, reverse its digits, and add these reversed numbers to the end of the array.
For example, if you have [13, 25], you'll reverse 13 to get 31 and 25 to get 52, resulting in the extended array [13, 25, 31, 52].
The challenge? Count how many distinct integers exist in the final array. Some numbers might appear multiple times (like when a number equals its reverse, such as palindromes), but you only count unique values.
Goal: Return the total count of distinct integers in the final transformed array.
Input & Output
Visualization
Time & Space Complexity
Single pass through array (O(n)) with digit reversal for each number (O(d) where d is average digits)
Hash set stores at most 2n distinct numbers (worst case when no duplicates)
Constraints
- 1 โค nums.length โค 105
- 1 โค nums[i] โค 106
- All integers in nums are positive
- Leading zeros are dropped when reversing (e.g., 1200 โ 21, not 0021)