Maximum Pair Sum Less Than Target

Given an integer array nums and an integer target, return the largest sum of two distinct elements that is strictly less than target. Return -1 when no such…

Given an integer array `nums` and an integer `target`, return the largest sum of two distinct elements that is strictly less than `target`. Return `-1` when no such pair exists.

- `2 <= nums.length <= 100` - `1 <= nums[i], target <= 10^9` - The interactive visualizer accepts at most 12 values; longer valid arrays are execution-only.

Example 1: input nums = [34,23,1,24,75,33,54,8], target = 60; output 58. The largest qualifying sum is 34 + 24.

Example 2: input nums = [8,9,10], target = 5; output -1. No pair sum is below 5.

Category: Two Pointers. Topic: two-pointers. Difficulty: Easy. Patterns: two-pointers, sorting.