subject

There is a straight line of students of various heights. The students' heights are given in in the form of an array, in the order, they are standing in the line. Consider the region of a student as the length of the largest subarray that includes that student's position, and in which that student's height is equal to maximum height among all students present in that subarray. Return the sum of the region of all students. For example- 1 > #!/bin/python3. 10 I 11 # 12 # Complete the calculateTotalRegion' function below. 13 # 14 # The function is expected to return a LONG_INTEGER. 15 # The function accepts INTEGER_ARRAY heights as parameter. 16 # 17 18 def calculateTotal Region (heights): 19 # Write your code here 20 21 > if _name == 'main':.
heights = (1, 2, 11 The longest subarray in which the first student's height is equal to maximum height among all other students is [1]; thus, the length of the region of the first student is 1.
The longest subarray in which the second student's height is equal to maximum height among all other students is [1, 2, 1); thus, the length of the region of the second student is 3.
The longest subarray in which the third student's height is equal to maximum height among all other students is [1]; thus, the length of the region of the third student is 1.
Thus, the sum of the lengths of all regions of all students is 1+3+1 = 5. Function Description Complete the function calculate TotalRegion in the editor below. The function must return the desired sum of all regions. calculate TotalRegion has the following parameter(s): heights, an array of the heights of students standing in the line Constraints
1 s length of heights s 105
1 s heights[i] s 10 Input Format For Custom Testing Line: 10 Col. 1 Sample Case o Test Results Run Custom Input

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 16:00, natasniebow
Kenny works with an it company. his company is about to launch new software in the market. he has to ensure that this new software is functional and meets all of the quality standards set up at the planning stage. which job profile is kenny likely to have? kenny is likely to have the job profile of a blank .
Answers: 2
image
Computers and Technology, 23.06.2019 16:30, saintsfan2004
How to do this programming flowchart?
Answers: 3
image
Computers and Technology, 23.06.2019 19:30, wilkinsonei4069
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a, b] se pot scrie ca produs de două numere prime? “.
Answers: 1
image
Computers and Technology, 24.06.2019 19:00, taridunkley724
Which of the following "invisible" marks represents an inserted tab?
Answers: 1
You know the right answer?
There is a straight line of students of various heights. The students' heights are given in in the f...

Questions in other subjects:

Konu
Mathematics, 05.02.2021 05:10
Konu
Arts, 05.02.2021 05:10
Konu
English, 05.02.2021 05:10
Konu
English, 05.02.2021 05:10
Konu
Mathematics, 05.02.2021 05:10
Konu
Mathematics, 05.02.2021 05:10