This question evaluates proficiency in array algorithms, pairing logic, data structure selection, and complexity analysis, focusing on maximizing disjoint k-sum pairs and reasoning about space–time trade-offs.
You are given an integer array nums and an integer k. In one operation you may remove two indices i < j if nums[i] + nums[j] == k; each index can be used at most once. Return the maximum number of operations you can perform. Design an O(n) or O(n log n) solution, discuss space–time trade-offs, and provide code in C, C++, Java, or JavaScript.