April 21, 2013

  • Leetcode Jump Game

    Given an array of non-negative integers, you are initially positioned at the first index of the array.
    Each element in the array represents your maximum jump length at that position.
    Determine if you are able to reach the last index.
    For example:
A = [2,3,1,1,4], return true.
    A = [3,2,1,0,4], return false.

    頂…我諗既方法次次都Time out…
    原本我諗住由尾數番上頭,另外開一條array儲住每一格去唔去到終點
    類似dynamic programming + memoization
    比佢最大既test case 整死左…

    上網睇人地用greedy algorithm, 極簡潔地KO左…

     

    Leetcode PathSum

    given一條binary tree, 搵下有無邊條root 至leaf既path既sum = a given number

    淨係做到D咁簡單既sosad

Post a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts

Recent Comments

Categories