Home

Published

- 1 min read

2442. Count Number of Distinct Integers After Reverse OperationsMy SubmissionsBack to Contest

img of 2442. Count Number of Distinct Integers After Reverse OperationsMy SubmissionsBack to Contest

The solution for this is noted below

2442. Count Number of Distinct Integers After Reverse OperationsMy SubmissionsBack to Contest

Solution

   class Solution:
    def countDistinctIntegers(self, nums: List[int]) -> int:
        reverseList = []
        for i in nums:
            temp = str(i)
            temp = temp[::-1]
            reverseList.append(int(temp))
        nums = nums + reverseList
        return len(set(nums))

Try other methods by searching on the site. That is if this doesn’t work