#3761

Minimum Absolute Distance Between Mirror Pairs

specialist · 960 · lc medium +32 · 44.3% accepted · 77 likes · top 27%

Description

Given an integer array nums, find all index pairs (i, j) with i < j where reverse(nums[i]) == nums[j] (reversing digits and dropping leading zeros, e.g., reverse(120) = 21), and return the smallest abs(i - j) among such mirror pairs, or -1 if none exist.

Code

1
2
3