We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0832a42 commit f57b2e2Copy full SHA for f57b2e2
57_codechef_A-books.cpp
@@ -0,0 +1,42 @@
1
+//
2
+// main.cpp
3
+// jdjd
4
5
+// Created by Prince Kumar on 26/09/19.
6
+// Copyright © 2019 Prince Kumar. All rights reserved.
7
8
+// --- codechef --> A-Books ---
9
+#include <iostream>
10
+using namespace std;
11
+int main()
12
+{
13
+ int T; cin>>T;
14
+ while(T--)
15
+ {
16
+ int n; cin>>n;
17
+ int a[n];
18
+ int b[1000001]={0};
19
+ // in b[] we store last index of elements
20
+ for(int i=0;i<n;i++) // i->index
21
22
+ int x; cin>>x;
23
+ a[i]=x;
24
+ b[x]=i;
25
+
26
+// cin>>a[i];
27
+// b[a[i]]=i;
28
+ }
29
+ for(int i=0;i<n;i++)
30
31
+ //cout<<n-1-b[a[i]]<<endl;
32
+ int x = a[i];
33
+ int last_index = b[x];
34
+ cout<<n-1-last_index<<" ";
35
36
+ cout<<endl;
37
38
39
+}
40
41
42
0 commit comments