Question: solve it in c++ run this code for 4 2 3 2 1 correct output is 3 A factory has n workers, who work in

solve it in c++

solve it in c++ run this code for 4 2 3 2

run this code for 4 2 3 2 1 correct output is 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 A1A2AN - 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 Format: M Here, " M " is an integer that represents the number of pairs of workers who can communicate safety issues to each other. Example

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!