Practice Count Almost Equal Pairs I
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Two positive integers are almost equal when they can be made equal using at most one digit swap in total. The swap exchanges any two digits within either chosen integer. Leading zeroes produced by the swap are allowed. Count pairs of indices i < j in nums whose values are almost equal.
Source: Count Almost Equal Pairs I on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [3,12,30,17,21]
Output
2
# Example 2
Input
nums = [1,1,1,1,1]
Output
10
# Example 3
Input
nums = [123,231]
Output
0
Constraints
2 <= nums.length <= 100
1 <= nums[i] <= 10^6
Related LeetCode Problems
Practice more problems similar to Count Almost Equal Pairs I.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.