We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bfb1532 commit e6679deCopy full SHA for e6679de
39_codechef_chef_and_Eid.cpp
@@ -0,0 +1,41 @@
1
+//
2
+// main.cpp
3
+// CODE-CHEF
4
5
+// Created by Prince Kumar on 14/05/19.
6
+// Copyright © 2019 Prince Kumar. All rights reserved.
7
8
+// ---- ** Chef and Eid ** ------
9
+
10
+#include <iostream>
11
+#include <vector>
12
+#include <algorithm>
13
+using namespace std;
14
+int main()
15
+{
16
+ int T;cin>>T;
17
+ while(T--)
18
+ {
19
+ int n ; cin>>n;
20
+ vector<int > v;
21
+ for(int i=0;i<n;i++)
22
23
+ // cin>>v[i];
24
+ int x; cin>>x;
25
+ v.push_back(x);
26
+ }
27
+ sort(v.begin(),v.end());
28
+ // sort
29
30
+ vector<int> res;
31
+ for(int i=0;i<n-1;i++)
32
33
+ res.push_back(v[i+1]-v[i]);
34
35
+ sort(res.begin(),res.end());
36
+ cout<<res[0]<<endl;
37
38
39
40
+}
41
0 commit comments