Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Plz solve it in netbeans 8.1 or 8.2 & use simple java lanquage (need all Qs to b

ID: 3814642 • Letter: P

Question

Plz solve it in netbeans 8.1 or 8.2 & use simple java lanquage (need all Qs to be solved not part of it )

THANK U

Problem 2:

--------------

Various signal towers are present in a city. Towers are aligned in a straight horizontal line (from left to right) and each

tower transmits a signal in the right to left direction. Tower A shall block the signal of Tower B if Tower A is present to

the left of Tower B and Tower A is taller than Tower B. So, the range of a signal of a given tower can be defined as:

{ (the number of contiguous towers just to the left of the given tower whose height is less than or equal to the height

of the given tower) + 1}.

You need to find the range of each tower.

INPUT

First line contains an integer T specifying the number of test cases.

Second line contains an integer n specifying the number of towers.

Third line contains n space separated integers(H[i]) denoting the height of each tower.

OUTPUT

Print the range of each tower (separated by a space).

Constraints

1 <= T <= 10

2 <= n <= 10^6

1 <= H[i] <= 10^8

SAMPLE INPUT

1

7

100 80 60 70 60 75 85

SAMPLE OUTPUT

1 1 1 2 1 4 6

Explanation

6th tower has a range 4 because there are 3 contiguous towers (3rd 4th and 5th towers) just to the left of the 6th

tower whose height is less than height of 6th tower.

Explanation / Answer

package chegg; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Tower { public static void main (String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine()); if (T>=1 && T 0) { //n should be integer as it satisfies the constraint 2
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote