Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Amazon Web Services has n servers where the ith server's vulnerability score is vulnerability [ i ] . A client wants to deploy their application

Amazon Web Services has n servers where the ith server's vulnerability score is vulnerability[i]. A client wants to deploy their application on a group of m contiguous servers. The vulnerability of a group is defined as the kth minimum vulnerability among the chosen servers. Find the vulnerability of each possible group of m contiguous servers the client can choose.
Example:
k =2
m =3
vulnerability =[1,3,2,1]
There are 2 contiguous groups of m =3 servers: [1,3,2] and [3,2,1].
The k =2nd lowest vulnerability in each group is 2.
Return the answers for each group, in order: [2,2].
Function Description
Complete the function findKthMinimumVulnerability in the editor below.
findKthMinimumVulnerability has the following parameter(s):
int k: the order of the vulnerability to find
int m: the number of servers in a group
int vulnerability[n]: the vulnerabilities of each server
Returns:
int[n - m +1]: the ith element represents the kth minimum vulnerability among the vulnerabilities of all the servers in the ith contiguous group.
Constraints
1<= k <= m <= n <=3*105
1<= vulnerability[i]<=109
Input Format For Custom Testing
The first line contains an integer, k, the order of the vulnerability to find.
The second line contains an integer, m, the number of servers in a group.
The third line contains an integer, n, the size of vulnerability.
Each line i of the n subsequent lines (where 0<= i < n) contains an integer, vulnerability[i].
Sample Case 0
Sample Input For Custom Testing
STDIN FUNCTION
-------------
3-> order of vulnerability k =3
4-> servers in a group m =4
5-> number of servers n =5
4-> vulnerability =[4,2,3,1,1]
2
3
1
1
Sample Output
3
2
Explanation
The first group of servers is [4,2,3,1] or [1,2,3,4] when sorted. The 3rd minimum vulnerability is 3.
The second group of servers is [2,3,1,1], or [1,1,2,3] when sorted. The 3rd minimum vulnerability is 2.
Sample Case 0
Sample Input For Custom Testing
STDIN FUNCTION
-------------
3-> order of vulnerability k =3
4-> servers in a group m =4
5-> number of servers n =5
4-> vulnerability =[4,2,3,1,1]
2
3
1
1
Sample Output
3
2
Explanation
The first group of servers is [4,2,3,1] or [1,2,3,4] when sorted. The 3rd minimum vulnerability is 3.
The second group of servers is [2,3,1,1], or [1,1,2,3] when sorted. The 3rd minimum vulnerability is 2.
Please write c++ code for the above and use older c++ versions with TC and SC

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

BPR always involves automation. Group of answer choices True False

Answered: 1 week ago