Generalize to the case where the sum of k elements is 0

A typical k-sum problem can be solve in  o( n^(k-1) ) using sorting.It requires (K-2) for loop and one while loop.

Refer this to understand process