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 18:30
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
question
Computers and Technology, 22.06.2019 22:10
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
Which argument is not a valid filter? does not equal this quarter filter by cell color all of these are valid filter arguments.
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
Write a grading program for a class with the following grading policies: a. there are two quizzes, each graded on the basis of 10 points. b. there is one midterm exam and one final exam, each graded on the basis of 100 points. c. the final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (do not forget to normalize the quiz scores. they should be converted to a percentage before they are averaged in.) any grade of 90 or more is an a, any grade of 80 or more (but less than 90) is a b, any grade of 70 or more (but less than 80) is a c, any grade of 60 or more (but less than 70) is a d, and any grade below 60 is an f. the program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. define and use a structure for the student reco
Answers: 2
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
Computers and Technology, 25.12.2019 01:31
question
Chemistry, 25.12.2019 01:31
question
History, 25.12.2019 01:31
question
Mathematics, 25.12.2019 01:31
Questions on the website: 13722360