Skip to content

Commit

Permalink
Create Collecting_Numbers.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukulguptaiit committed Jan 9, 2025
1 parent 249321c commit 7ae546b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Collecting_Numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
#include <vector>
using namespace std;

int main() {
int n;
cin >> n;
vector<int> vs(n+1,0);

for(int i=1;i<n+1;i++){
int temp;
cin>>temp;
vs[temp]=i;
}
int count=0;
for(int i=2;i<n+1;i++){
if(vs[i-1]>vs[i]){
count++;
}
}
cout<<count+1;
return 0;
}

0 comments on commit 7ae546b

Please sign in to comment.