Two pointers: Given nums and target, choose two distinct elements and return the minimum absolute difference between their sum and target. Return null when fewer than two elements are available.
Input: A JSON object { "nums": number[], "target": number }.
Output: A JSON number for the minimum absolute difference, or null when no pair exists.
Constraints:
- 0 <= nums.length <= 100000
- nums may be unsorted and may contain duplicates
- A pair must use two distinct indexes
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: HARD. Variant: 24. Favor a pragmatic solution that is easy to ship, read, and adapt.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked hard difficulty.
The signed-in