We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c745fba commit 704f912Copy full SHA for 704f912
Arrays/QueryingArray.cpp
@@ -0,0 +1,37 @@
1
+/*
2
+Given an array containing N elements where 1<=N<=100000, and given Q queries, for each query increment the subarray
3
+[L,R] by 1. At the end, print the final elements.
4
+
5
6
+*/
7
8
+// THIS SOLUTION IS INCOMPLETE
9
10
+#include<iostream>
11
12
+using namespace std;
13
14
+int main(int argc, char const *argv[])
15
+{
16
+ int N,Q,l,r,i=0;
17
+ int arr[N];
18
+ int B[N]={0};
19
+ cin>>N;
20
+ for(int i=0;i<N;i++)
21
+ {
22
+ cin>>arr[i];
23
+ }
24
25
+ cin>>Q;
26
+ while(Q--)
27
28
+ cin>>l>>r;
29
+ B[l]+=1;
30
+ B[r+1]-=1;
31
32
+ for(i=0;i<N;i++)
33
34
+ arr[i] =
35
36
+ return 0;
37
+}
0 commit comments