Question: solve it in c++/java/python also check it on 4 2 3 2 1 output correct output will be 3 A factory has n workers, who
solve it in c++/java/python

also check it on 4 2 3 2 1 output correct output will be 3
A factory has n workers, who work in a straight line. Each worker can see the workers on either side of them. If a worker sees a safety issue, they can notify the workers next to them. However, if there is a taller worker between them, they cannot see each other and the safety issue may go unnoticed. Your task is to write a program that determines how many pairs of workers are able to communicate safety issues to each other. Input Format: N A1 A2AN - The first line of the input data contains an integer N : the number of workers in the factory. - The second line contains N space-separated integers - denotes the heights of the workers. Output Fornjat: M Here, " M " is an integer that represents the number of pairs of workers who can communicate safety issues to each other. Example: Input: 5 23432 Output: 3 Explanation: The pairs of workers who can communicate safety issues are (1,2),(2,3), and (3,4). Thus the output is 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
