Am I wrong with this?


  • 0
    P

    the greedy algorithm has the assumption with there is one solution.
    What if the input like [5,4,3,2,1,0,0]?


  • 0
    M

    Using the greedy algorithm, if there is no solution, you will reach a point where there are no points reachable ahead of you. At that point, if you are at the end of the array, you've solved it, if not, return no solution.


Log in to reply
 

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