Best time to buy and sell stocks is one of the most popular type of problem series asked in various interviews. The problem basically consists of the prices of stocks on each day and requires us to find the maximum profit that can be obtained by buy...

Markdown supported · ⌘↵ to post
Tong Nong Lin
Hi, regarding to problem IV, you mentioned
approach 2
For every stock, calculate cash in hand after buying and selling it in the two arrays. This is done in a loop j from 1 till k where j denotes the cash in hand after jth buy and sell.
so j is from 1 to k
but in code, j is from k to 1?
btw, your linkedln is locked and can't send message