Doubt on line 24

This is the solution given in the video lecture and it works fine. But my doubt is why does k go from i to j, shouldn’t it be i to j-1. when k = j, it is the same problem as i to j which is what we are trying to find.
BTW both i to j and i to j-1 give correct answer.

link: https://ide.codingblocks.com/s/276513