Maximum sub array sum equal to k
What you implemented is different from what you were asked. Both the numbers in the array as well as k can be positive and negative, while it seems like you assumed both are strictly positive. 

Even if you made those assumptions, it still doesn't produce the desired output. For example, if your list of numbers were 5,10,2,4 and your sum is 12, then your subroutine would return 0 when it should return 1.