Unit 6 dynamic programming 6.1 example: Digital triangle
6.1 example: Digital triangle
[problem description] there is a digital triangle with layer number n (n ≤ 1000) (as shown in the figure below). There is an ant walking down from the top floor. When walking down one level, it can go down left or right. Find the maximum value of the sum of the numbers it passes through after going to th ...
Posted by Cut on Fri, 24 Sep 2021 21:02:29 -0700
Maximum common string, maximum common subsequence, edit distance, myers and other algorithms
1 Preface
The four algorithms are similar, and have the following similarities and differences
2 similarities and differences
Take STR1 = "ABCDEF", STR2 = "zabcdze" as an example
Similarities:
1. Get a target on a string; 2. The core of the algorithm is the idea of dynamic programming.
difference:
1. The targets are d ...
Posted by dreado on Fri, 24 Sep 2021 06:04:22 -0700
Force deduction question 10 regular expression matching (difficult)
Give you a string s And a character rule p. Please implement a support '.' and '*' Regular expression match for.
'.' matches any single character '*' matches zero or more preceding elements The so-called matching is to cover whole character string s, not part of the string.
Example ...
Posted by Frapster on Fri, 24 Sep 2021 02:02:08 -0700
Artillery position solution
Title Description
The generals of the command are going to be in n × M's grid map deploys their artillery forces. An n × The map of M consists of N rows and m columns. Each grid of the map may be mountainous (represented by H) or plain (represented by P), as shown in the following figure. At most one artillery unit can be deployed ...
Posted by tstout2 on Mon, 20 Sep 2021 18:19:39 -0700
PTA-L3-023-calculation diagram, and some of my thoughts on the calculation diagram
Portal
Define dp1[u] the function value of the function composed of all points reachable by u sign; dp2[u] represents the partial derivative value of the function composed of all points reachable by u to the variable represented by varIdx, where varIdx is enumerated one by one outside the dp2 solution process and input.
Because we build an in ...
Posted by stefandv on Mon, 20 Sep 2021 08:40:16 -0700
Algorithm improvement course template
Algorithm improvement course template
Chapter 1 dynamic programming
275. Slip of paper (Digital triangle model)
The note has to be passed to each other through many students. Obuchi sits in the upper left corner of the matrix, coordinates (1,1), and Xiaoxuan sits in the lower right corner of the matrix, coordinates (m,n). The note from Xiaoy ...
Posted by dotwebbie on Sun, 19 Sep 2021 23:25:31 -0700
[difficult] best stock trading opportunity
problem
Given an array arr of length N, its ith element is the price of a given stock on day i. Design an algorithm to calculate the maximum profit you can make. You can complete up to k transactions. You cannot participate in multiple transactions at the same time (you must sell the previous shares before buying again).
[dynamic planning ide ...
Posted by v0id on Sun, 19 Sep 2021 01:45:36 -0700
B-business-NC14545(dp Backpack + concurrent search)
B - doing business
Problem solution discuss View submissions from others My submission
Title No.: NC14545 Time limit: 1 second for C / C + + and 2 seconds for other languages Space limitation: C/C++ 32768K, other languages 65536K 64bit IO Format: %lld
Title Description
Xiao d is a local tyrant engaged in rea ...
Posted by plouka on Sun, 19 Sep 2021 01:41:24 -0700
7-1 matrix chain multiplication problem (20 points) (thinking + detailed explanation + topic analysis) dynamic programming practice
1: Title:
The multiplication of matrix is defined as follows: let A be m × The matrix of P, B is p × N, then the product of A and B is m × The matrix of n is written as C=AB, where the element C in row i and column j of matrix C ij It can be expressed as: c ij =Σ k=1 p a ik ×b kj =a i1 b 1j +a i2 b 2j +⋯+a ...
Posted by eaglelegend on Sat, 18 Sep 2021 15:23:59 -0700
Netease written test 4 questions
1. Divide the goods equally
Now there are n items, and each item has a value. Now I want to distribute these items to two people. It is required that the total value of the items distributed by each of the two people is the same (the number can be different, and the total value can be the same). The remaining items need to be thrown away. Now ...
Posted by rrhody on Sat, 18 Sep 2021 06:56:33 -0700