-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathChef_and_Card_Trick.cpp
98 lines (92 loc) · 1.72 KB
/
Chef_and_Card_Trick.cpp
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <iterator>
#include <vector>
using namespace std;
int main() {
int t;
cin>>t;
while (t--)
{
int N;
cin>>N;
vector <int > arr(N);
vector<int> sorted_array;
for (int i = 0; i < N; i++)
{
cin>>arr[i];
}
cout<<"Input Array\n";
for (int i = 0; i < N; i++)
{
cout<<arr[i]+"+";
}
cout<<"\n";
sorted_array=arr;
sort(sorted_array.begin(),sorted_array.end());
cout<<"Sorted Array\n";
for (int i = 0; i < N; i++)
{
cout<<sorted_array[i]+"_";
}
cout<<"\n";
for (int i = 0; i < N-1; i++)
{
if(!(arr[i+1]>arr[i])){
//arr.push_back(arr[i]);
//arr.erase(arr.begin());
}
}
cout<<"After operation Array"<<endl;
for (int i = 0; i < N; i++)
{
cout<<arr[i]+"^";
}
cout<<"\n";
bool b=true;
for (int i = 0; i < N; i++)
{
if(arr[i]!=sorted_array[i]){
b=false;
break;
}
}
if (b)
{
cout<<"YES\n";
}
else{
cout<<"NO\n";
}
}
return 0;
}
// 1
// 10
// 6 7 8 9 10 1 2 3 4 5
// Input Array
// rted Array
// ted Array
// ed Array
// d Array
// Array
// Sorted Array
// orted Array
// Sorted Array
// Sorted Array
// orted Array
// rted Array
// ted Array
// ed Array
// d Array
// Array
// After operation Array
// ted Array
// ed Array
// d Array
// Array
// Sorted Array
// orted Array
// Array
// NO