Computers and Technology

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

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:00, bnvghnbbb
Match the following. 1. show grouping of word processing tasks that can be performed quick access toolbar 2. shortcut location for commonly used elements scroll bars 3. organized commands used to modify documents ribbon 4. used to align and measure content in a word screen zoom bar 5. vertical and horizontal bars that are used to navigate through a document contextual tabs 6. displays the name of the document in use ruler 7. allows users to enlarge or shrink a visual of a word document title bar
Answers: 2
image
Computers and Technology, 22.06.2019 19:20, bob4059
1)consider the following code snippet: #ifndef book_h#define book_hconst double max_cost = 1000.0; class book{public: book(); book(double new_cost); void set_cost(double new_cost); double get_cost() const; private: double cost; }; double calculate_terms(book bk); #endifwhich of the following is correct? a)the header file is correct as given. b)the definition of max_cost should be removed since header files should not contain constants. c)the definition of book should be removed since header files should not contain class definitions. d)the body of the calculate_terms function should be added to the header file.
Answers: 1
image
Computers and Technology, 24.06.2019 10:30, brandon1748
You're programming an infinite loop. what must you include in your code to prevent crashes? in roblox
Answers: 2
image
Computers and Technology, 25.06.2019 02:30, LilCookies1
Ahammer should not be applied to the gear shafts of an electric rotisserie because the shafts may be made of
Answers: 1
Do you know the correct 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
History, 27.07.2019 05:30