#2815

Max Pair Sum in an Array

easy · 60.4% accepted · 436 likes · top 59%

array · hash table

Description

You are given an integer array nums. You have to find the maximum sum of a pair of numbers from nums such that the largest digit in both numbers is equal.

For example, 2373 is made up of three distinct digits: 2, 3, and 7, where 7 is the largest among them.

Return the maximum sum or -1 if no such pair exists.

Solution