In general it looks OK to me, but you could maybe consider the following:
1) Return a IEnumerable<int[]>
instead of List<List<int>>
and then yield the positive results when found:
...
else if (sumSoFar == sum)
{
yield return new int[] { iValue, jValue, kValue };
}...
2) 3 * (long)maxInput < (long)sum
: This cast has really no meaning because sum
never exceeds int.MaxValue. And if it had, you should make the same cast in the last test: 3 * sortedInput[0] > sum
What you could do was to first check if 3 * (long)maxInput > int.MaxValue
and then if 3 * maxInput < sum
.
3) The names sumI, sumJ, sumK are somewhat misleading because they aren't sums. Better names would be valueI, -J, -K
int valueI;
int valueJ;
int valueK;
43) For the fun of it, you could consider: Because you basically do the same same loop nested three times, it could be a candidate for a recursive function iterating over each addend and yielding all the positive sums. In that way you could generalize the algorithm to handle any number of addends...