From 61f8ee5512731f94ed256b3326e025b52b5cd45d Mon Sep 17 00:00:00 2001 From: Sahil Sharma <65874790+sahil2311sharma@users.noreply.github.com> Date: Mon, 4 Oct 2021 00:07:55 +0530 Subject: [PATCH] Permutation Minimization By Deque Issue #472 Permutation Minimization By Deque Issue Solved --- .../PermutationMinimizationByDeque.cpp | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 C++ Programs/PermutationMinimizationByDeque.cpp diff --git a/C++ Programs/PermutationMinimizationByDeque.cpp b/C++ Programs/PermutationMinimizationByDeque.cpp new file mode 100644 index 00000000..bd274da1 --- /dev/null +++ b/C++ Programs/PermutationMinimizationByDeque.cpp @@ -0,0 +1,65 @@ +/*---------------------------------------Header Files---------------------------------------*/ + +#include +using namespace std; + +/*---------------------------------------MACROS---------------------------------------*/ + +#define times_run long long ___tc=1; cin >> ___tc; while (___tc-- ) +#define rep(i,x,y) for(int i=x;i>n>>node; + + deque dq; + dq.push_back(node); + rep(i, 1, n) + { + cin >> node; + if (node > dq[0]) + { + dq.pb(node); + } + else + { + dq.pf(node); + } + } + while (!dq.empty()) + { + cout << dq.front() << " "; + dq.pop_front(); + } +} + +int32_t main() +{ + start_func(); + times_run + { + chalochale(); + nl + } + return 0; +}