Interval DP: Gene splicing
5 (optional) gene splicing (100 points) Gene splicing is the joining of different DNA fragments. The existing n DNA fragments line up from left to right. Each time two adjacent DNA fragments were selected and stitched into a longer DNA fragment. The last DNA fragment was adjacent to the first. Repeat this process until all the DNA fragments for ...
Added by dookie on Tue, 01 Feb 2022 17:50:26 +0200
Dynamic programming: interval d p summary
1, Interval dp
As the name suggests, interval dp is the problem of solving the optimal value on the interval.
The main idea is to solve the inter cell first, and then use the optimal solution combination between cells to obtain the optimal solution of the maximum interval.
If you don't say much, go straight to the example:
Classic example: ...
Added by greenba on Mon, 31 Jan 2022 12:08:53 +0200
[algorithm cultivation] dynamic programming topic 2: knapsack type problem
Learning from: https://labuladong.gitee.io/algo/3/25/85/
1, 0-1 knapsack problem
Give you a backpack with a weight of W and N items. Each item has two attributes: weight and value. Among them, the weight of the ith item is wt[i], and the value is val[i]. Now, what is the maximum value of the item you can pack with this back? It should be n ...
Added by Helljumper on Sun, 30 Jan 2022 15:33:13 +0200
2022 Niuke winter vacation algorithm basic training camp 3
I went to visit relatives that day. Later, I vp got away with it. I can only say that I escaped from the real hell (Wuwuwuwu was killed by brother zhinai). 6 in the game and 8 after the game, it was estimated that rank was about 450, so I gave an estimated score
A: Successful, 0
B: Backpack, 6 (1)
C: dp (supplementary)
D: Check in, 2
E: An ...
Added by evil turnip on Sun, 30 Jan 2022 02:13:31 +0200
Knapsack problem of dynamic programming (under construction)
knapsack problem
1, 01 knapsack problem
each item can only be selected or not, and each item can only be selected once
Topic overview:
title link: 01 knapsack problem
Solution:
f(i,j) represents the maximum value when only the first i items are viewed and the total volume is j. Our answer is max{f(n,k),k ...
Added by mrclark219 on Sun, 30 Jan 2022 00:51:23 +0200
OJ topic -- 1. Create an array to store the number of characters in the string
1. Find the first character in the string that appears only once: The first character that appears only once_ Niuke Tiba_ Niuke (nowcoder.com)
Since the characters in the computer are ultimately represented by the asker code, you can create an array, and the number of times each character appears will be placed in the subscript position corres ...
Added by Chicken Little on Sat, 29 Jan 2022 18:21:07 +0200
[algorithm cultivation] dynamic programming topic 1: basic problem solving skills, subsequence problems, array traversal order
1, Basic problem solving skills of dynamic programming
Learning from: https://labuladong.gitee.io/algo/3/23/71/
1.1 change exchange (medium)
Make four points of analysis on the topic: base case, state (variables changed in the original problem and sub problem), selection (what causes the state to change), and the meaning of dp array
B ...
Added by steve@MRS on Thu, 27 Jan 2022 17:19:06 +0200
Dynamic programming solution of knapsack problem
1: Title:
knapsack problem
Question: two arrays, a weight array W, a value array V, and a backpack bag. If the return does not exceed the backpack capacity, the maximum value will be returned
2: Violent solution
Idea: brute force traversal. The idea is to select or deselect the current item during recursion. If so, there will be several ...
Added by Tdm on Wed, 26 Jan 2022 23:17:27 +0200
[algorithm exercise] LeetCode - dynamic programming learning plan
The title comes from: https://leetcode-cn.com/study-plan/dynamic-programming/?progress=nc4eyhc
Climbing stairs (simple)
class Solution {
public int climbStairs(int n) {
if (n <= 2 ) {
return n;
}
int[] ans = new int[n + 1];
ans[1] = 1;
ans[2] = 2;
for (int i = 3; i <= n; ...
Added by phuggett on Wed, 26 Jan 2022 09:59:19 +0200
Dynamic Planning Theme (Three Examples: Simple, Medium, Medium)
Example 1: Continuous series (simple interview question 16.17)
Title link: Force bucklehttps://leetcode-cn.com/problems/contiguous-sequence-lcci/
Title: Given an array of integers, find the largest continuous sequence of sums and return the sum.
Example:
Input: [-2, 1, -3, 4, -1, 2, 1, -5, 4]
Output: 6
Interpretation: The sum of cons ...
Added by excl209 on Wed, 26 Jan 2022 08:24:32 +0200