Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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++
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. ExampleStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started