#3267
Count Almost Equal Pairs II
international master · 2070 · lc hard +32 · 27% accepted · 81 likes · top 5%
Description
Attention: In this version, the number of operations that can be performed has been increased to twice.
You are given array nums of positive integers. Two integers are almost equal if one can be made equal to the other using at most two digit swaps within it (leading zeros allowed).
Return the count of pairs (i, j) with i < j where nums[i] and nums[j] are almost equal.
Code
1
2
3