[basic algorithm course] Chapter 4 Summary of knapsack series templates of dynamic programming
Backpack series
State representation f(i,j)
aggregate
AllMeet the conditions attribute
Maximumminimum valuequantity... State calculation
1, 01 Backpack
Features: each item can only be used once (or not)
State calculation: divide the set into selected i and unselected i
1.1 simple writing (two-dimensional)
/**
* f[i][j]Indi ...
Added by jscnet on Sun, 24 Oct 2021 15:59:02 +0300
The 22nd CSP certification question 4 tree outside the school gate (3 methods, very detailed) (class dp + Mathematics)
Link: Official website: http://118.190.20.162/view.page?gpid=T125 Acwing: https://www.acwing.com/problem/content/description/3417/ Question meaning: give the unequal points of N on the number axis in sequence and record it as sequence A. first divide the large interval [a[0],a[N-1]] into several sub intervals [li,ri), and then select several p ...
Added by mayus on Fri, 22 Oct 2021 12:36:26 +0300
Logu P2196 Mining Problem Solution Super Detail (DP&DFS)
Topic Portal
When I read this question, I thought of two ways, dp and search, so I gave them two ways
1.dp
This question is put on the introduction of the "dp" on the form, so let's think about it with DP first
dp needs to consider array, transfer equation
1. Arrays
Undoubtedly, this type of dp question uses a one-dimensional ar ...
Added by tsilenzio on Sun, 17 Oct 2021 19:22:14 +0300
[Leetcode monotone stack] 84. The largest rectangle in the histogram (dp optimized double pointer calculation with jump saving calculation!! how to think about the problem solution!!)
Leetcode84
1. Problem description
2. Solutions
Solution 1: double pointer (O(n^2) timeout) (thinking about a solution to the problem
1. I can understand it by looking at the figure. For each column, the largest rectangle containing this column is the area between the first smaller column on the left and right, and then find the ma ...
Added by Buddha443556 on Wed, 13 Oct 2021 03:28:03 +0300
Force deduction question 1035: disjoint lines, question 1049: dynamic programming to solve the weight of the last stone (Java)
1, Foreword
Today is an exception. I did two questions because I thought I met the first question two days ago, so I was familiar with it. I soon wrote it out, and then I wanted to write one more question. As a result, the second question is still very routine. Let's start with these two questions today.
2, Title ...
Added by Plasma on Mon, 11 Oct 2021 23:05:31 +0300
LeetCode question 98 -- verifying binary search tree
This article will share the solution ideas and steps of LeetCode question 98 in detail, hoping to bring help to you.
preface
Binary tree is a very important data structure. It involves a wide range of algorithms. Whether it is an amazing backtracking algorithm or an amazing dynamic programming, it is closely related to binary tree, whic ...
Added by geaser_geek on Thu, 07 Oct 2021 03:38:15 +0300
Detailed explanation of three programming questions in Huawei's 2021 written test
catalogue
2021 Huawei written test first
Cache forwarding packet statistics (100%)
Problem solving ideas:
Reference code:
2021 Huawei written examination question 2
Find instance knowledge in the knowledge map (100%)
Problem solving ideas:
Reference code:
2021 Huawei written test question 3
Lake connectivity (100%)
Problem sol ...
Added by madspof on Sat, 25 Sep 2021 21:59:59 +0300
Combination of KMP with AC automata and DP
Design password Now you need to design a password
S
,
S
S,S
S. S needs to meet:
S The length of the is N;
S Contains only lowercase English letters;
S Contains no substrings T;
For example:
...
Added by cjacks on Wed, 22 Sep 2021 01:23:51 +0300
Dynamic programming problem
1. Stair climbing: there are n stairs in total. You can only climb 1 or 2 stairs at a time. How many methods are there to climb n stairs?
Idea: assuming there are 10 stairs in total, when completing the 9th stair, you can complete the 10th stair by going up one step. When the 8th stair is completed, it can also be completed by going up the 2nd ...
Added by Arenlor on Sun, 19 Sep 2021 11:04:22 +0300
Dynamic programming -- learning now
Which problems can be solved by dynamic programming?
count
How many ways to get to the lower right cornerHow many ways to choose k numbers so that Sum is Sum Find the maximum and minimum value
The maximum number and number of paths from the upper left corner to the lower right cornerLongest rising sequence length Seeking existence
Wil ...
Added by cybernet on Fri, 17 Sep 2021 17:24:29 +0300