MB
Yes j is from k to 1, by mistake I wrote 1-k. Thanks for pointing it! j runs from k to 1 because for a current price i, if I decide to buy it at kth transaction, I would subtract this price from my profit at j-1. j can't run from 1 till k because then profit at j-1 would contain the value of profit after selling current price itself at k-1 th transaction. Hence we move from back so that our value at jth transaction doesn't get affected by values of current price from different situations where we can buy and sell it.