From 79f67e49604d65b0a0ef91267d3e81039b915047 Mon Sep 17 00:00:00 2001 From: Rohit Vishwakarma <128726730+RohitVishwakarma8840@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:35:23 +0530 Subject: [PATCH] Create Stack --- C++/Stack | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 C++/Stack diff --git a/C++/Stack b/C++/Stack new file mode 100644 index 000000000..d22f8c9d2 --- /dev/null +++ b/C++/Stack @@ -0,0 +1,68 @@ +class Solution { + public: + vector makeBeautiful(vector arr) { + + stacks; + + for(int i=0;i=0){ + + // non-negative + if(s.top()>=0){ + s.push(arr[i]); + } + // negative + else{ + s.pop(); + } + + } + + // Negative No + else{ + if(s.top()<0){ + s.push(arr[i]); + } + else{ + s.pop(); + } + + + } + + + + } + + + vectorans(s.size()); + int i = s.size()-1; + while(!s.empty()){ + ans[i]=s.top(); + i--; + s.pop(); + + + } + + + return ans; + + + + + + + + + + + + } +};