Is one of the test cases wrong?


  • 0
    A

    So one of the test cases said I was wrong and I'm confused as to why:

    Input: 2, [1,2,4,2,5,7,2,4,9,0]
    Output: 12
    Expected: 13

    I would have thought the 2 greatest profits are between [2,5,7] = 5 and [2,4,9]=7 and 7+5=12 which is what I outputted yet the test case is expecting 13, can someone please explain?


  • 0
    I

    LOL have u tried buy 1 sell 7 then buy 2 sell 9? should get u 13.
    I am stuck with a case where k = 1000000 and it caused my recursive stack to overflow...damn


  • 0
    I

    :DDDD didn't see u closed it pal. Have u got the final answer?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.