Leetcode 1048. Longest String Chain - Dynamic Programming

preview_player
Показать описание
A Dynamic Programming solution to Leetcode 1048. Longest String Chain. In this approach, we initialize a dp table in the form of dictionary where word:length pairs are recored. The length is the current maximal word chain length ending at the word. We sort the words in length then scan it, and update the dp table by consider possible predecessors in the words (can be regarded as a set) of each word by deleting one character in the word. The potential longest word chain can be easily retrieved by examining the final state of the dp table.

At time 11:02, we mean the Rotting Oranges problem, i.e., Leetcode 994.
Рекомендации по теме
join shbcf.ru