All Tracks Data Structures Advanced Data Structures Segment Trees Problem

Range Minimum Query
Tag(s):

Very-Easy

Problem
Editorial
Analytics

Given an array A of size N, there are two types of queries on this array.

  1. \(q l r\): In this query you need to print the minimum in the sub-array \(A[l : r]\).
  2. \(u x y\): In this query you need to update \(A[x] = y\).

Input:
First line of the test case contains two integers, N and Q, size of array A and number of queries.
Second line contains N space separated integers, elements of A.
Next Q lines contain one of the two queries.

Output:
For each type 1 query, print the minimum element in the sub-array \(A[l : r]\).

Contraints:
\(1 \le N, Q, y \le 10^5\)
\(1 \le l, r, x \le N\)

SAMPLE INPUT
5 5
1 5 2 4 3
q 1 5
q 1 3
q 3 5
u 3 6
q 1 5
SAMPLE OUTPUT
1
1
2
1
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications

?