We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 3a963d6 + 5fec192 commit 4f0656cCopy full SHA for 4f0656c
1 file changed
Problems/Data-structures/Day-09/sol/Devanshu/Solution1.cpp
@@ -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
26
+ if(p[i]>=a && p[i]<=b){
27
+ count++;
28
29
30
+ cout<<count<<endl;
31
32
33
+}
0 commit comments