Question: Please write a C Code for this problem. Please do not submit C++ or Python Code. You are standing facing N pillars of different heights
Please write a C Code for this problem. Please do not submit C++ or Python Code.


You are standing facing N pillars of different heights with pillar having height The pillars are one behind the other, so if a pillar of height 4 is behind a pillar of height 10, you won't be able to see it. You want to know how many pillars you will be able to see in the range [L, R] both inclusive. For example, if there are five pillars and the range is [0,4], then yau want to know how many pillars you can see altogether; but if the range is [0.2], then you want to know how many pillars you can see among the first three, and so on. Input: The first line contains an integer N denoting the number of pillars. Next line contains N integers denoting height of ith pillar. Next line contains a single integer Q. Next Q lines contain pairs L and Rrespectively. Output: For every Q queries print the number of buildings visible in the range [L, R]. Constraints: IMV,QSIOS Sample Input:
Step by Step Solution
3.48 Rating (168 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
