Leetcode - Arithmetic Slices II - Subsequence (Python)

preview_player
Показать описание
September 2021 Leetcode Challenge
Leetcode - Arithmetic Slices II - Subsequence #446
Difficulty: Hard
Рекомендации по теме
Комментарии
Автор

Tim. Thank you very much for your videos. Very clear and helpful!

binarysearch
Автор

Hi! Can you explain more the part about making sure the subsequence has at least three elements (output += dp[j][diff])?

Edit: After slowly going through the loops, my understanding is that basically dp[j][diff] would be 0 if i = 1. Once i = 2, then dp[j][diff] would actually have a value and thus start accumulating in the output variable. Is this correct?

phillipwei
visit shbcf.ru