当前位置:网站首页>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
边栏推荐
- Ag9310 design USB type C to hdmi+u2+5v slow charging scheme design | ag9310 expansion dock scheme circuit | type-C dongle design data
- How to get the first and last days of a given month
- About snake equation (2)
- NPDP在国内有认可度吗?看一看就明白了!
- 3. Multi agent reinforcement learning
- The Ministry of housing and urban rural development officially issued the technical standard for urban information model (CIM) basic platform, which will be implemented from June 1
- Chapter XI feature selection
- About snake equation (5)
- Cs5261type-c to HDMI alternative ag9310 | ag9310 alternative
- How does Matplotlib generate multiple pictures in turn & only save these pictures without displaying them in the compiler
猜你喜欢

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

Problems of font legend and time scale display of MATLAB drawing coordinate axis

The persistence mode of redis - RDB and AOF persistence mechanisms

Write a pure handwritten QT Hello World

The beauty of Mathematics -- the principle of fine Fourier transform

The difference between distribution function and probability density function of random variables

5、離散控制與連續控制

EDP to LVDS conversion design circuit | EDP to LVDS adapter board circuit | capstone/cs5211 chip circuit schematic reference

2021-03-14 - play with generics

2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
随机推荐
The persistence mode of redis - RDB and AOF persistence mechanisms
How does Matplotlib and PIL image integrate and save multiple pictures into one picture
About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware
4、策略学习
2021-04-12 - new features lambda expression and function functional interface programming
NPM internal split module
小金额炒股,在手机上开户安全吗?
Introduction to natural language processing (NLP) based on transformers
2022 R1 fast opening pressure vessel operation test question bank and R1 fast opening pressure vessel operation free test questions
Common effects of line chart
Grey correlation analysis link (portal) matlab
Problems of font legend and time scale display of MATLAB drawing coordinate axis
2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search
Connect to the previous chapter of the circuit to improve the material draft
LeetCode 练习——剑指 Offer 36. 二叉搜索树与双向链表
Basic implementation of pie chart
STM32GPIO口的工作原理
Redis master-slave replication
break net
USB type-C docking design | design USB type-C docking scheme | USB type-C docking circuit reference