We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef8e20b commit 8c32945Copy full SHA for 8c32945
1 file changed
Data Structures/Minimum Subsequent Value.cpp
@@ -1,16 +1,19 @@
1
struct MyQ{
2
- deque<int> D,Min;
3
- void push(int val){
4
- D.push_back(val);
5
- while(!Min.empty() && Min.back()>val) Min.pop_back();
6
- Min.push_back(val);
+ deque<int> D, Min;
+
+ void push( int val ) {
+ D.push_back( val );
+ while( !Min.empty() && Min.back() > val ) Min.pop_back();
7
+ Min.push_back( val );
8
}
- void pop(){
9
- if(Min.front()==D.front() )
10
+ void pop() {
11
+ if( Min.front() == D.front() )
12
Min.pop_front();
13
D.pop_front();
14
- int get(){
15
16
+ int get() {
17
return Min.front();
18
19
};
0 commit comments