当前位置:网站首页>Break algorithm --- map
Break algorithm --- map
2022-07-08 01:31:00 【killingwill】
Resource reference :
LeetCode
Chinese version :https://leetcode-cn.com/problemset/all/
English version :https://leetcode.com/problemset/all/
Related code implementation – python Language :
https://github.com/muxintong/break-algorithm/
LeetCode Problem solving summary
https://github.com/labuladong/fucking-algorithm
https://labuladong.gitee.io/algo/
https://grandyang.com/leetcode/1147/
Python3 file
https://docs.python.org/3/
data structure
https://www.runoob.com/data-structures/
Problem Solving with Algorithms and Data Structures using Python
https://runestone.academy/runestone/books/published/pythonds/index.html
- 1.1 Introduction to monotone stack
- 1.2 On behalf of the topic
- 1.2.1 Daily temperature (739)
- 1.2.2 Remove duplicate letters (316)
- 1.2.3 Maximum sliding window (239_ difficult _O(n) Time complexity resolution )
- 1.2.4 The largest rectangle (85)
- 1.2.5 Next bigger element II(503)
- 1.2.6 The largest rectangle in the histogram (84_ difficult )
- 1.2.7 Rainwater collection (42_ difficult _ Performance sensitive )
- 1.2.8 Stock price span (901)
- 2.1 And look up the introduction
- 2.2 On behalf of the topic
- 2.2.1 Circle of friends (547)
- 2.2.2 Redundant connections (684)
- 2.2.3 Number of Islands (200_ Must do )
- 2.2.4 Sentence similarity II (737_ members )
- 2.2.5 The path with the highest score (1102_ members )
- 2.2.6 Connect all cities at the lowest cost (1135_ members )
- 2.2.7 Distinguish trees by pictures (261_ members )
- 2.2.8 The smallest equivalent string in lexicographic order (1061_ members )
- 2.2.9 The number of connected components in an undirected graph (323_ members )
- 2.2.10 Minimize the spread of malware (924_ difficult )
3、 ... and . The sliding window
- 3.1 Slide window Introduction
- 3.2 On behalf of the topic
- 3.2.1 Make strings equal as much as possible (1208)
- 3.2.2 Subarray with the smallest length (209)
- 3.2.3 Longest substring without repeating characters (3)
- 3.2.4 Maximum continuous 1 The number of III (1004)
- 3.2.5 At most K Longest substring of different characters (340_ members _ difficult )
- 3.2.6 The minimum number of exchanges to combine all 1(1151_ members )
- 3.2.7 The longest substring containing at most two different characters (159_ members )
- 3.2.8 The length is K There is no repetition in the string (1100_ members )
- 3.2.9 Minimum cover substring (76)
- 3.2.10 String arrangement (567)
- 3.2.11 Look for all the letter ectopic words (438)
6、 ... and . A topological sort
- 8.1 BFS Introduce
- 8.2 On behalf of the topic
- 8.2.1 The word chain (127)
- 8.2.2 Word splitting (139)
- 8.2.3 The surrounding area (130)
- 8.2.4 The nearest distance to the building (317)
- 8.2.5 maze II (505_ members )
- 8.2.6 The Minesweeper game (529)
- 8.2.7 tuixiangzi (1263)
- 8.2.8 The attacking Knight (1197_ members )
- 8.2.9 Bus routes (815)
- 8.2.10 The shortest bridge (934)
- 10.1 Introduction to dynamic planning
- 10.2 On behalf of the topic
- 10.2.1 raid homes and plunder houses II(213)
- 10.2.2 Separate the arrays to get the maximum and (1043)
- 10.2.3 To divide into equal and subsets (416)
- 10.2.4 The best time to buy and sell stocks III(123)
- 10.2.5 Different paths (62)
- 10.2.6 Different paths II (63)
- 10.2.7 4 Key keyboard (651_ members )
- 10.2.8 Bombing the enemy (361)
- 10.2.9 School bike Distribution II(1066_ members )
- 10.2.10 The number of corner rectangles (750_ members )
- 10.2.11 Toss a coin (1230)
- 10.2.12 The shortest path to form a string (1055_ members )
11、 ... and . Greedy Algorithm
One . Monotonic stack |
1.1 Introduction to monotone stack
Monotonic stack :
- Definition : A stack in which elements are monotonically increasing or decreasing , Monotone stack can only operate at the top of the stack .
Monotonic stack = monotonous + Stack , Therefore, it meets two characteristics at the same time : monotonicity 、 The characteristics of the stack .
monotonicity : The data stored in the monotone stack is orderly ( Monotonically increasing or decreasing ).
Stack : Last in, first out . - Realization : The elements in a monotone stack are monotonous , Before the element is added to the stack , At the top of the stack, the elements that break the monotony of the stack are deleted .
Monotonically decreasing stacks : Find the first element larger than the current element from the left
stack<int> st;
for ( Traverse the array )
{
if ( The stack is empty || The stack top element is greater than or equal to the current comparison element )
{
Push ;
}
else
{
while ( Stack is not empty. && The stack top element is smaller than the current element )
{
Stack top element out of stack ;
Update results ;
}
Current data stack ;
}
}
The above code optimization merge :
stack<int> st;
for( Traversal array ){
while( The current element > Top element of stack && The stack is not empty ){
Bomb stack ;//catch it! Found the first element larger than the current element from the left !
Update result set ;
}
The current element is put on the stack ;
}
Monotonically increasing stacks : Find the first element smaller than the current element from the left
stack<int> st;
for(int i=0; i<arr.length; i++){
while( The current element < Top element of stack && The stack is not empty ){
Bomb stack ;//catch it! Found the first element smaller than the current element from the left !
Update result set ;
}
The current element is put on the stack ;
}
- Time complexity :O(n)
linear , Each element is traversed once .
Because it satisfies monotonicity and each number will only be put on the stack once , And they will never enter the stack again after they are out of the stack , So we can reduce the time complexity O(n) Solve some problems in the case of . - application :
- Monotonically increasing stack can be found from left first Elements smaller than the current number
- Monotonic decreasing stack can be found from left first Elements larger than the current number
边栏推荐
- Content of one frame
- Introduction to the types and repair methods of chip Eco
- 解决报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
- Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
- About snake equation (3)
- Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board
- 2021-03-14 - play with generics
- Redis master-slave replication
- Basic realization of line graph
- Understanding of expectation, variance, covariance and correlation coefficient
猜你喜欢
About snake equation (5)
2021 tea master (primary) examination materials and tea master (primary) simulation test questions
The solution of frame dropping problem in gnuradio OFDM operation
Application of state mode in JSF source code
break net
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
General configuration toolbox
Transportation, new infrastructure and smart highway
Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
写一个纯手写的qt的hello world
随机推荐
Gnuradio 3.9 using OOT custom module problem record
Two methods for full screen adaptation of background pictures, background size: cover; Or (background size: 100% 100%;)
2021 tea master (primary) examination materials and tea master (primary) simulation test questions
Chapter XI feature selection
从cmath文件看名字是怎样被添加到命名空间std中的
解决报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Running OFDM in gnuradio_ RX error: gr:: Log: info: packet_ headerparser_ b0 - Detected an invalid packet at item ××
Blue Bridge Cup embedded (F103) -1 STM32 clock operation and led operation method
HDMI to VGA acquisition HD adapter scheme | HDMI to VGA 1080p audio and video converter scheme | cs5210 scheme design explanation
NPM Internal Split module
Definition and classification of energy
Basic implementation of pie chart
NPDP在国内有认可度吗?看一看就明白了!
2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search
Application of state mode in JSF source code
Write a pure handwritten QT Hello World
COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况---材料的添加
The examination contents of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge) in 2021 and the free examination questions of the third batch of Guangdong Prov
How to get the first and last days of a given month
Different methods for setting headers of different pages in word (the same for footer and page number)