As reported: Omnissa (formerly VMware) Senior Python Developer, Bengaluru (2026), round 2, first coding problem: given an array and
k, find the maximum pair sum less thank; a brute-force answer was given and the interviewer wanted the optimal one.
Given an integer array nums and an integer k, return the maximum nums[i] + nums[j] with i ≠ j that is strictly less than k, or -1 if no pair qualifies. This is LeetCode 1099 — Two Sum Less Than K.
Example 1
nums = [34,23,1,24,75,33,54,8], k = 60 -> 58 (34 + 24)
Example 2
nums = [10,20,30], k = 15 -> -1
Constraints: 1 ≤ nums.length ≤ 100; 1 ≤ nums[i] ≤ 1000; 1 ≤ k ≤ 2000.
Code runner format: one JSON value per line: nums, then k (LeetCode's format). Implement twoSumLessThanK(nums, k); the harness prints the sum.