Easy
You are given an integer array nums.
An integer in nums is a Mirror Exception if reversing its digits (ignoring leading zeros) produces an integer that is not in nums.
Return the value of the Mirror Exception, or -1 if none exists.
It is guaranteed that at most one distinct value in nums is a Mirror Exception, even if it appears multiple times.
Example 1:
Input: nums = [19,18,18,18,91]
Output: 18
Explanation:
- The distinct integers in
numsare 18, 19, and 91. - The reverse of 19 is 91, which is present in
nums. - The reverse of 91 is 19, which is present in
nums. - The reverse of 18 is 81, which is not present in
nums. - Therefore, 18 is the Mirror Exception.
Example 2:
Input: nums = [7]
Output: -1
Explanation:
- The reverse of 7 is 7 itself, which is present in
nums. - Therefore, no Mirror Exception exists, and we return -1.
Constraints:
1 <= nums.length <= 1001 <= nums[i] <= 100- It is guaranteed that at most one distinct value in nums is a Mirror Exception.