What is the largest subsequence of LeetCode 53
Today, I will talk to you about what the largest subsequence of LeetCode 53 is. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
1. Exhaustive framework
The idea of exhaustive framework is:
All values of for state 1 in state 1: for state 2 all values of in state 2: for... Dp [status 1] [status 2] [...] = preferred (select 1, select 2.)
The "state" of this topic is one-dimensional, the data loop in the array. There are two kinds of "choice": put in and do not put. Exhaustive framework is easy to understand, the difficulty is the state transition framework, how to write the correct state transition is the biggest problem.
two。 State transition framework
The explanation is that
Dp [I] = Math.max (num [I], dp [I-1] + num [I])
Dp [] defines an one-dimensional array to record each dynamic transfer process, which can be seen as a basic problem.
What is the relationship between dp [I] and DP [I-1] and num [I] (the current element)? In fact, it is also understood from a business point of view.
After reading the above, do you have any further understanding of what is the largest subsequence of LeetCode 53? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.