Maximizing profit for given stock quotes

后端 未结 9 1903
無奈伤痛
無奈伤痛 2020-12-07 09:45

I was asked this question while interviewing for a startup and saw this again in the recent contest at

Code Sprint:systems

**The question :

You are

9条回答
  •  庸人自扰
    2020-12-07 10:43

    your logic is correct...

    sell at global maxima's..but recursion is not required...

    if ith element is global maxima...sell all stocks before i!

    Now problem reduces to previous answer+ i+1 to N...

    recursion is not required...linearly we can calculate!

提交回复
热议问题