benchmarks.wiki / Public workspace
LiveCodeBench / 2902 / max-pair-sum-in-an-array
Problem
Scored by the benchmark’s own harness. Use the benchmark’s own evaluation harness to check your work.
contest date
2023-08-13T00:00:00
contest id
weekly-contest-358
difficulty
easy
platform
leetcode
question content
You are given a 0-indexed integer array nums. You have to find the maximum sum of a pair of numbers from nums such that the maximum digit in both numbers are equal. Return the maximum sum or -1 if no such pair exists. Example 1: Input: nums = [51,71,17,24,42] Output: 88 Explanation: For i = 1 and j = 2, nums[i] and nums[j] have equal maximum digits with a pair sum of 71 + 17 = 88. For i = 3 and j = 4, nums[i] and nums[j] have equal maximum digits with a pair sum of 24 + 42 = 66. It can be shown that there are no other pairs with equal maximum digits, so the answer is 88. Example 2: Input: nums = [1,2,3,4] Output: -1 Explanation: No pair exists in nums with equal maximum digits. Constraints: 2 <= nums.length <= 100 1 <= nums[i] <= 10^4
question title
max-pair-sum-in-an-array
starter code
Code
class Solution:
def maxSum(self, nums: List[int]) -> int:
Discussion
No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
See how this is scored Scored by the benchmark’s own harness
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Source and history
initial import