Leetcode 2342. Max Sum of a Pair With Equal Sum of Digits 中文解說

Опубликовано: 16 Июль 2026
на канале: Billour Ou
54
1

2342. Max Sum of a Pair With Equal Sum of Digits

重點在於: the sum of digits of the number nums[i] is equal to that of nums[j]. 這句英文,
指的是 例如[18,43,36,13,7], 其中18 sum of digits 是 1+8 =9, 36 是 3+ 6 =9 兩者都是 9, 不是兩數的最大公因數 [18, 36] both numbers have a sum of digits equal to 9, and their sum is 18+36 =54

[18,43,36,13,7] 轉化之後為 [9,7,9,4,7]。所以,(0, 2), (1, 4)相同

其他的條件式:
1. nums 從0開始, 0-indexed
2.全部都是正數integers, consisting of positive integers.
3.回傳最大值maximum, 比較後的最大值, Return the maximum value of nums[i] + nums[j] that you can obtain over all possible indices I and j that satisfy the conditions.