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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:00
Jackson is teaching the decimal number system. he wants his students to know how to expand numbers by powers of 10. which is the correct order in which digits are assigned values in the decimal number system?
Answers: 1
question
Computers and Technology, 22.06.2019 13:30
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. centurion: a commander in the army of ancient rome. keyword: picture:
Answers: 2
question
Computers and Technology, 22.06.2019 15:30
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
question
Computers and Technology, 22.06.2019 19:40
Solve the following javafx application: write a javafx application that analyzes a word. the user would type the word in a text field, and the application provides three buttons for the following: - one button, when clicked, displays the length of the word.- another button, when clicked, displays the number of vowels in the word.- another button, when clicked, displays the number of uppercase letters in the word(use the gridpane or hbox and vbox to organize the gui controls).
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
question
Mathematics, 19.03.2021 16:00
question
Mathematics, 19.03.2021 16:00
question
Spanish, 19.03.2021 16:00
Questions on the website: 13722362