-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathminimum_stack2.cpp
More file actions
54 lines (45 loc) · 1.21 KB
/
Copy pathminimum_stack2.cpp
File metadata and controls
54 lines (45 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//Question : https://youtu.be/BhYvZ4kVaug?list=PL-Jc9J83PIiFj7YSPl2ulcpwy-mwj1SSk
/*
Explanation : https://www.pepcoding.com/resources/online-java-foundation/stacks-and-queues/minimum_stack_2_constant_space/topic
The previous problem required us to make a minimum stack using constant time.
However this question demands to do it in constant space.
*/
// Solution : https://youtu.be/Trz7JM610Uc?list=PL-Jc9J83PIiFj7YSPl2ulcpwy-mwj1SSk
#include<iostream>
#include<fstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<utility>
#include<unordered_map>
#include<set>
#include<map>
#include<unordered_set>
#include<string>
#include<limits.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
int main()
{
/*
All operations are same as normal stack , we have to implement an extra function which returns
min of all elements present in the stack now in constant time O(1) and constant space
*/
/*
Logic :
*/
stack<int> st;
while(1)
{
//Menu Driven Program
cout<<"Press 1 to push.\n";
cout<<"Press 2 to pop.\nPress 3 to find min.\nPress any other keys to exit.\n";
int ch;
cin>>ch;
//TODO :
}
}