Review of algorithm analysis
Algorithm review
Basics
Complexity calculationSolving recurrences
Brute force method
TSP KMP
Divide and conquer
thought
Divide similar subproblems, solve subproblems recursively, and then merge subproblems
Typical problems
Maximum sub segment sum
Subproblem Solve the left and right largest fields and Solve the maximum field su ...
Posted on Mon, 06 Dec 2021 19:11:20 -0500 by PAFTprod
Interview questions of dynamic programming of leetcode
1. Maximum sum of continuous subarrays
Enter an integer array array with length n. one or consecutive integers in the array form a sub array. Find the maximum value of the sum of all subarrays.
Data range:
1 <= n <= 10^51<=n<=105
-100 <= a[i] <= 100−100<=a[i]<=100
Requirement: the time complexity is O (n), spa ...
Posted on Sat, 04 Dec 2021 19:47:51 -0500 by Chief
Dynamic Planning - Example 6. Polygon Game
1. Title Description
A Polygon game is a one-player game that starts with a polygon with n vertices. Each vertex is assigned an integer value, and each edge is assigned an operator'+'or'*'. All edges are numbered from 1 to n using integers in turn.
Step 1 of the game, delete an edge.
Then step n-1 operates as follows:
(1) Select an edge E and t ...
Posted on Wed, 01 Dec 2021 14:29:58 -0500 by AudiS2
Dynamic Planning - Example 7. Image Compression
1. Title Description
A digitized image is an n*n array of pixels. Assuming that each pixel has a gray value of 0-255, it requires at most 8 bits to store a pixel.
To reduce storage space, a variable-length mode is used, that is, different pixels are stored in different bits, as follows:
Image Linearization: Convert a nn-dimensional image to an ...
Posted on Tue, 30 Nov 2021 16:32:25 -0500 by Mr_Mako
The sixth sort -- quick sort
void quickSort(vector<int>& v, int left, int right) {
if (left >= right)return;
int pirot = v[right];
int leftField = left;
int rightField = right;
for (; leftField < rightField; leftField++) {
if (v[leftField] <= pirot)continue;
else {
rightField--;
swap(v, leftField, rightField);
leftField--;//Because w ...
Posted on Sun, 28 Nov 2021 08:58:31 -0500 by retoknaak
Implementation of C/C + + development based on VSCode and CMake | Linux
Implementation of C/C + + development based on VSCode and CMake | Linux
Construction of development environment
Before installing the software, perform sudo apt update update software installation package= Package and install gcc g++ gbd with sudo apt install build essential DBG
To view the installation results:
Installing CMake
s ...
Posted on Sun, 28 Nov 2021 05:11:03 -0500 by donbre
LeetCode 1320. The second refers to the minimum distance of input -- Dynamic Programming -- interval DP
The second refers to the minimum distance entered
The layout of the two finger input method customized keyboard on the XY plane is shown in the above figure, in which each uppercase English letter is located at a certain coordinate, for example, the letter A is located at the coordinate (0,0), the letter B is located at the coordinate (0,1), ...
Posted on Fri, 26 Nov 2021 17:24:01 -0500 by mmorton
Dynamic programming: interval DP (learning record)
It can be said that it is the first part of self-study. At the beginning, it was because I met similar problems on oj. There was also a problem in the freshman competition (I don't want to recall...) that used this part of knowledge. Let's have a look. (there are many things I want to write in this article. I hope I won't lose it)
Example: 104 ...
Posted on Thu, 25 Nov 2021 17:15:13 -0500 by mmosel
Dynamic programming - classification summary
Dynamic programming (DP) idea
Dynamic programming = > DP
Dynamic programming: ordinary recursion + dp array records to achieve space for time
Dynamic programming is generally not very efficient because dp[] it records the optimal solution of each state on the way
Try to find clever methods to achieve better solutions than dp
Three properties ...
Posted on Wed, 24 Nov 2021 14:13:23 -0500 by michalchojno
2021 icpc Shenyang J-Luggage Lock
Immediately after the game ended, there was a replay with the team-mates and they were beaten up. _J is to give you a lock with 4 digits, each of which is 0-9, and then give you the current lock status and password status. You can move up or down several consecutive positions at the same time, or you can move in a single position to ask you how ...
Posted on Sun, 21 Nov 2021 15:04:36 -0500 by burnside