当前位置:网站首页>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
边栏推荐
- Ag7120 and ag7220 explain the driving scheme of HDMI signal extension amplifier | ag7120 and ag7220 design HDMI signal extension amplifier circuit reference
- 从cmath文件看名字是怎样被添加到命名空间std中的
- Common configurations in rectangular coordinate system
- STM32GPIO口的工作原理
- Continued from the previous design
- 写一个纯手写的qt的hello world
- After modifying the background of jupyter notebook and adding jupyterthemes, enter 'JT -l' and the error 'JT' is not an internal or external command, nor a runnable program
- ROS 问题(topic types do not match、topic datatype/md5sum not match、msg xxx have changed. rerun cmake)
- USB type-C mobile phone projection scheme | USB type-C docking station scheme | TV / projector type-C converter scheme | ag9300ag9310ag9320
- Application of state mode in JSF source code
猜你喜欢

Chapter 16 intensive learning
Common fault analysis and Countermeasures of using MySQL in go language

STM32GPIO口的工作原理

The persistence mode of redis - RDB and AOF persistence mechanisms
![Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small](/img/ab/066923f1aa1e8dd8dcc572cb60a25d.jpg)
Gnuradio operation error: error thread [thread per block [12]: < block OFDM_ cyclic_ prefixer(8)>]: Buffer too small

qt--将程序打包--不要安装qt-可以直接运行

The communication clock (electronic time-frequency or electronic time-frequency auxiliary device) writes something casually

USB type-C mobile phone projection scheme | USB type-C docking station scheme | TV / projector type-C converter scheme | ag9300ag9310ag9320

Generic configuration legend

Redis 主从复制
随机推荐
Problems of font legend and time scale display of MATLAB drawing coordinate axis
2021-04-12 - new features lambda expression and function functional interface programming
Matlab code about cosine similarity
5. Contrôle discret et contrôle continu
Basic implementation of pie chart
break algorithm---刷题map
Kuntai ch7511b scheme design | ch7511b design EDP to LVDS data | pin to pin replaces ch7511b circuit design
Talk about smart Park
Capstone/cs5210 chip | cs5210 design scheme | cs5210 design data
Introduction to the types and repair methods of chip Eco
3、多智能体强化学习
Chapter 5 neural network
Kindle operation: transfer downloaded books and change book cover
Continued from the previous design
LaTeX 中 xcolor 颜色的用法
The usage of rand function in MATLAB
Smart agricultural technology framework
2022 high voltage electrician examination skills and high voltage electrician reexamination examination
Write a pure handwritten QT Hello World
Understanding of prior probability, posterior probability and Bayesian formula