Search
⌘K

Leetcode 1814. Count Nice Pairs in an Array

Count pairs i<j where nums[i] + rev(nums[j]) == nums[j] + rev(nums[i]); the condition is equivalent to nums[i] - rev(nums[i]) == nums[j] - rev(nums[j]), so the task reduces to counting pairs of indices with the same transformed value and returning the result mod 1e9+7. Constraints: n up to 1e5 and nums[i] up to 1e9.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.