Arithmetic Slices II - Subsequence


  • 0
    T

    Click here to see the full article post


  • 0

    Check out my dfs solution in discussion, it's much faster :)


  • 0
    P

    Good explanation.
    I think there is a minor typo, and correct me if I am wrong,
    for this line:
    for all j < i, f[i][A[i] - A[j]] += f[j][A[i] - A[j]],
    it means that only when there is an arithmetic subsequence ending at A[j], then we could add that count to the new subsequence ending at A[i]. But it misses the case when the subsequence ending at A[j] is a weak one.


Log in to reply
 

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