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
Inputnums = [1,13,10,12,31]
Output6
After including each reversed number, the final array contains the distinct integers 1, 10, 12, 13, 21, and 31.
Example 2
Inputnums = [2,2,2]
Output1
Reversing 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

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate