this is related to the following question:
Generalised 3SUM (k-SUM) problem?
Without loss of generality, let's only consider even $k$, or just $k=4$.
My question is, after summing all pairs of numbers, is it necessary to sort the list of sums? I understand we could use two pointers from left and right to sandwich the two pairs in $O(n^2)$ time, but the sorting requires $O(n^2\log(n))$ time.
If we use a hashmap to store the sums as key and their corresponding index pairs as value, then all operations can run in $O(n^2)$ time.
Am I missing something in that post or is it true for even $k$, $k$-sum can run in $O(n^{k/2})$ time?
Thanks!