values. For each number, look at the largest digit in its decimal form: for 4719 it is 9, for 305 it is 5.
Pick two different elements of the array whose largest digits are equal so that their sum is as large as possible. Return that sum, or -1 if no such pair exists.values=[38, 83, 15, 51, 80] → 163
38, 83 and 80 all have 8 as their largest digit; 15 and 51 have 5. The best pair is 83 + 80 = 163.
values=[12, 34, 56] → -1
The largest digits 2, 4 and 6 are all different, so no pair qualifies.
values=[7, 70, 107, 9] → 177
len(values) ≤ 100values[i] ≤ 10⁴values=[38, 83, 15, 51, 80]
163
Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.