Skip to content

Commit dd58e7b

Browse files
authored
commit of the code for the DS n algos
1 parent 71d22ee commit dd58e7b

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

1200A.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include<iostream>
2+
#include<conio.h>
3+
4+
using namespace std;
5+
6+
int main(){
7+
string s;
8+
string s1;
9+
cin>>s;
10+
cout<<endl;
11+
cin>>s1;
12+
if(s == '1'){
13+
cout<<"okay"<<endl;
14+
}
15+
else if (s1 == s){
16+
cout<<"okay 2"<<endl;
17+
}
18+
else{
19+
cout<<"Wrong entry"<<endl;
20+
}
21+
22+
getch();
23+
return 0;
24+
}

1213B.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include<iostream>
2+
#include<conio.h>
3+
#include<algorithm>
4+
#include<vector>
5+
6+
7+
using namespace std;
8+
9+
#define INF (int) 1e19
10+
11+
int main(){
12+
int n;
13+
int T;
14+
cin>>T;
15+
while (T-->0){
16+
cin>>n;
17+
vector <int> v1;
18+
for(int i= 0;i<n;i++){
19+
cin>>v1[i];
20+
}
21+
//creating a 2nd vector
22+
vector <int> v2;
23+
int min_val = INF;
24+
for(int i=n-1;i>-1;i--){
25+
min_val = min(min_val,v1[i]);
26+
v2[i] = min_val;
27+
}
28+
int ans = 0;
29+
for(int i=0;i<n-1;i++){
30+
if(v1[i] > v2[i+1]){
31+
ans++;
32+
}
33+
}
34+
cout<<ans<<endl;
35+
}
36+
getch();
37+
return 0;
38+
}

0 commit comments

Comments
 (0)