Template NSum problem is most likely solved by: sort the array Iterate the outer (L-2) layers two-pointers search in the inner most 2 layers. So the time complexity is: O(L^(N-1)), L is length of array, N is number of elements to NSum.