#K61332. Building Heights Query
Building Heights Query
Building Heights Query
You are given N buildings arranged in a line, with their heights given in an array A. You will receive Q queries. Each query is described by three integers l, r, and k. For each query, determine if there exists at least one building in the subarray from index l to r (1-indexed, inclusive) whose height is greater than or equal to k. Output "yes" if such a building exists and "no" otherwise.
Note: The indices provided are 1-indexed. You should handle conversion to 0-indexed if necessary in your code.
Example:
Input: 5 3 3 1 4 2 5 1 3 4 2 4 2 1 5 6</p>Output: yes yes no
inputFormat
The first line contains two space-separated integers N (the number of buildings) and Q (the number of queries).
The second line contains N space-separated integers, representing the heights of the buildings.
Then Q lines follow, each containing three space-separated integers: l, r, and k, which represent a query asking whether there exists a building with height greater than or equal to k in the subarray from index l to r (inclusive).
outputFormat
For each query, output a single line containing "yes" if there exists at least one building in the specified subarray with height greater than or equal to k, otherwise output "no".
## sample5 3
3 1 4 2 5
1 3 4
2 4 2
1 5 6
yes
yes
no
</p>