Tap here to switch tabs
Problem
Submissions

Problem: Max Sum of a Pair With Equal Sum of Digits

Max Sum of a Pair With Equal Sum of Digits gives an integer array and asks for the largest sum of two elements at distinct indices whose digit sums match, or minus one if none do.

Statement

Given an integer array nums, choose two distinct indices i and j such that the sum of digits of nums[i] is equal to the sum of digits of nums[j]. Among all such valid pairs, return the maximum possible value of nums[i] + nums[j]. If no valid pair exists, return -1.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Max Sum of a Pair With Equal Sum of Digits

Max Sum of a Pair With Equal Sum of Digits gives an integer array and asks for the largest sum of two elements at distinct indices whose digit sums match, or minus one if none do.

Statement

Given an integer array nums, choose two distinct indices i and j such that the sum of digits of nums[i] is equal to the sum of digits of nums[j]. Among all such valid pairs, return the maximum possible value of nums[i] + nums[j]. If no valid pair exists, return -1.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9