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, 23.06.2019 01:40
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
question
Computers and Technology, 23.06.2019 09:30
You have been supporting csm tech publishing's windows server 2016 server network for over a year. the office has two windows server 2016 servers running active directory and a number of other roles. management has informed you that a small sales office is opening in the same building three floors up. the sales manager wants to install a sales application on a server located in the sales office. this server will have limited physical security because there's no special room dedicated for it, which means it will be accessible to non-it personnel and visitors. you're considering installing windows server 2016 server core on the new server because accessing its console regularly probably won't be necessary, and this server will be managed from one of the other csm tech publishing servers. what are the benefits and drawbacks of using server core for this branch office? what are some things you should do to set up this server management environment?
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
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
Mathematics, 16.11.2020 03:20
question
History, 16.11.2020 03:20
question
Physics, 16.11.2020 03:20
question
Mathematics, 16.11.2020 03:20
question
Physics, 16.11.2020 03:20
question
Mathematics, 16.11.2020 03:20
Questions on the website: 13722361