values. Two elements at different positions make a pair if their digit sums are equal (for example, 15 and 42 both have digit sum 6).
Return the largest sum of two numbers that make a pair. If there is no pair at all, return -1.values=[24, 51, 15, 60, 33] → 111
24, 51, 15, 60 and 33 all have digit sum 6. The two largest are 60 and 51, giving 111.
values=[7, 70, 12, 3] → 77
7 and 70 have digit sum 7; 12 and 3 have digit sum 3. The best pair is 7 + 70 = 77.
values=[5, 14, 22] → 19
The digit sums are 5, 5 and 4, so the pair 5 and 14 gives 19.
values=[24, 51, 15, 60, 33]
111
Run checks the first 3 tests in your browser. Submit checks all 118 tests on the server, hidden ones included.