当前位置:网站首页>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
边栏推荐
- Taiwan Xinchuang sss1700 latest Chinese specification | sss1700 latest Chinese specification | sss1700datasheet Chinese explanation
- 2021-03-14 - play with generics
- Matlab code on error analysis (MAE, MAPE, RMSE)
- redis的持久化方式-RDB和AOF 两种持久化机制
- Running OFDM in gnuradio_ RX error: gr:: Log: info: packet_ headerparser_ b0 - Detected an invalid packet at item ××
- Leetcode notes No.21
- qt--將程序打包--不要安裝qt-可以直接運行
- About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware
- npm 内部拆分模块
- Four digit nixie tube display multi digit timing
猜你喜欢

5. Contrôle discret et contrôle continu

Kuntai ch7511b scheme design | ch7511b design EDP to LVDS data | pin to pin replaces ch7511b circuit design

The persistence mode of redis - RDB and AOF persistence mechanisms

Scheme selection and scheme design of multifunctional docking station for type C to VGA HDMI audio and video launched by ange in Taiwan | scheme selection and scheme explanation of usb-c to VGA HDMI c

On the concept and application of filtering in radar signal processing

Content of one frame

QT -- package the program -- don't install qt- you can run it directly
Common fault analysis and Countermeasures of using MySQL in go language

Recommend a document management tool Zotero | with tutorials and learning paths

qt-使用自带的应用框架建立--hello world--使用min GW 32bit
随机推荐
NPM Internal Split module
Ag9310meq ag9310mfq angle two USB type C to HDMI audio and video data conversion function chips parameter difference and design circuit reference
Grey correlation analysis link (portal) matlab
The combination of relay and led small night light realizes the control of small night light cycle on and off
ROS 问题(topic types do not match、topic datatype/md5sum not match、msg xxx have changed. rerun cmake)
FIR filter of IQ signal after AD phase discrimination
Definition and classification of energy
Deep learning website
About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware
About snake equation (5)
Transportation, new infrastructure and smart highway
Plot function drawing of MATLAB
Capstone/cs5210 chip | cs5210 design scheme | cs5210 design data
Smart grid overview
Arm bare metal
Basic implementation of pie chart
redis的持久化方式-RDB和AOF 两种持久化机制
小金额炒股,在手机上开户安全吗?
Cs5261type-c to HDMI alternative ag9310 | ag9310 alternative
Multi purpose signal modulation generation system based on environmental optical signal detection and user-defined signal rules