2342. Max Sum of a Pair With Equal Sum of Digits
Содержание
class Solution:
def maximumSum(self, nums: List[int]) -> int:
d = defaultdict(int)
res = -1
for v in nums:
x, y = 0, v
while y:
x += y % 10
y //= 10
if x in d:
res = max(res, d[x] + v)
d[x] = max(d[x], v)
return res