Maximum Sum
You are given an array(of integers) of length n.Input Format
You are required to answer q queries.
Queries can be of two types :-
Update
0 idx val : set arr[idx] to val.
Query
1 l r: find i,j such that l <= i < j <= r, such that arr[i]+arr[j] is maximized. return arr[i]+arr[j].
A number nOutput Format
n1
n2
.. n number of elements
A number q
following q lines contains queries of format either of two
0 idx val
1 l r
for each query of type 1 print a single integer in seperate lineQuestion Video
1. 1 <= n, q <= 10^5Sample Input
2. 0 <= l < r < n
3. 0 <= idx < n
4. 1 <= arr[i], val <= 10^4.
8Sample Output
2
6
1
5
4
10
10
9
5
1 0 4
0 0 10
1 0 4
1 0 7
1 3 4
11
16
20
9
-
Asked in Companies
-
Related Topics
Video Solution
Code Solution
{ }
{ }
Run