Given an array with integers, find the maximum sum of any 2 numbers whose first and last digits match.
E.g - [ 2, 36, 45, 306, 415] -> 36 + 306 < 45 + 415
Ans - 460
Examples
01 · Example 1
nums = [2, 36, 45, 306, 415] return = 460
The maximum sum of any 2 numbers whose first and last digits match is obtained by adding 45 and 415, which gives us 460.
More Microsoft problems
- Rank Open BusinessesPHONE SCREEN · Seen May 2026
- Retain Top K ValuesPHONE SCREEN · Seen May 2026
- In-Memory SQL with CSV InitializationONSITE INTERVIEW · Seen May 2026
- Order Records by Matching Start and EndONSITE INTERVIEW · Seen May 2026
- Recover Corrupted Master PageONSITE INTERVIEW · Seen Feb 2026
- Get Minimum TimeSeen Jun 2025
- Count Subarrays with Bitwise OR PresentSeen Jun 2025
- Get Max Or SumSeen Jun 2025
public int findMaxSumWithSameFirstAndLastDigit(int[] nums) {
// write your code here
}
nums[2, 36, 45, 306, 415]
expected460
sign in to submit