← 返回 capitalone 的题目列表Count Numbers With One Different Digit
类型:online_judge
capitalone
Given an array of numbers, count the pairs of numbers that have the same number of digits but differ by exactly one digit.
Input:
An array arr of positive integers, where each element is a number
Output:
The count of number pairs that satisfy the condition
Example:
Input: [123, 124, 321, 423, 456]
Output: 2
Notes:
Pairs like (123, 124) and (123, 423) satisfy the condition
Pairs like (123, 321) do not satisfy the condition as they differ by more than one digit
Constraints:
The array has a positive length
All numbers have the same digit-length
Example
Input
[123, 124, 321, 423, 456]