#3265

Count Almost Equal Pairs I

expert · 1045 · lc medium +32 · 38.2% accepted · 159 likes · top 17%

Description

You are given array nums of positive integers. Two integers are almost equal if one can be made equal to the other by swapping two of its digits at most once (leading zeros allowed).

Return the number of pairs (i, j) with i < j where nums[i] and nums[j] are almost equal.

Code

1
2
3