Skip to content

Practice Count Nice Pairs in an Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1814
LeetCode Problem

Count Nice Pairs in an Array

Problem Statement

Let rev(x) reverse the decimal digits of nonnegative x, discarding any leading zeros in the reversed result. Count index pairs i < j satisfying nums[i] + rev(nums[j]) = nums[j] + rev(nums[i]). Return the count modulo 10^9 + 7.

Source: Count Nice Pairs in an Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [42,11,1,97]
Output
2

# Example 2

Input
nums = [13,10,35,24,76]
Output
4

Constraints

1 <= nums.length <= 10^5
0 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Count Nice Pairs in an Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.