Search⌘ K
AI Features

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

C# solution for the Max Sum of a Pair With Equal Sum of Digits problem using the Hash Maps pattern.

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 ...