393. Minimum Absolute Distance Between Mirror Pairs
MediumHash Table
You are given an integer array nums. A mirror pair is a pair of indices (i, j) such that: - 0 <= i < j < nums.length, and - reverse(nums[i]) == nums[j], where reverse(x) denotes the integer formed by reversing the digits of x. Leading zeros are omitted after reversing, for example reverse(120) = 21. Return the minimum absolute distance between the indices of any mirror pair. The absolute distance between indices i and j is abs(i - j). If no mirror pair exists, return -1.
Examples
Input: [12,21,45,33,54]
Output: 1
Explanation: Public test case for Minimum Absolute Distance Between Mirror Pairs
Constraints
- 1 <= nums.length <= 10^5
- 1 <= nums[i] <= 10^9
Loading...
Run checks all cases above. Submit evaluates all test cases.