Skip to content

Commit 704f912

Browse files
committed
added program in Arrays
1 parent c745fba commit 704f912

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Arrays/QueryingArray.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)