Skip to content

Commit 5fec192

Browse files
authored
Update and rename solution1.cpp to Solution1.cpp
1 parent f3f2911 commit 5fec192

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Approach: Simply store the value in the array, mae if-else statements and filter the values.
2+
Time Complexity: O(nq)
3+
Code:​
4+
#include <bits/stdc++.h>
5+
using namespace std;
6+
int main(){
7+
int n;
8+
int q;
9+
cin>>n>>q;
10+
int p[n];
11+
for(int i=0;i<n;i++){
12+
cin>>p[i];
13+
}
14+
for(int i=0;i<q;i++){
15+
char c;
16+
cin>>c;
17+
if(c=='!'){
18+
int k, x;
19+
cin>>k>>x;
20+
p[k-1]=x;
21+
}
22+
else if(c=='?'){
23+
int a,b,count=0;
24+
cin>>a>>b;
25+
for(int i=0;i<n;i++){
26+
if(p[i]>=a && p[i]<=b){
27+
count++;
28+
}
29+
}
30+
cout<<count<<endl;
31+
}
32+
}
33+
}

Problems/Data-structures/Day-09/sol/Devanshu/solution1.cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)