Problem Β· Sliding Window

Find Kth Minimum Vulnerability

● MediumAmazonFULLTIMEOA
See Amazon hiring insights

Note πŸ“ - Another problem related to find server vulnerability Find Least Possible Vulnerability πŸ¦₯

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.

Function Description

Complete the function findKthMinimumVulnerability in the editor below.

findKthMinimumVulnerability has the following parameter(s):

  1. int k: the order of the vulnerability to find
  2. int m: the number of servers in a group
  3. int vulnerability[n]: the vulnerabilities of each server

Returns

int[]: the vulnerabilities for each group, in order

Examples
01 Β· Example 1
k = 2
m = 3
vulnerability = [1, 3, 2, 1]
return = [2, 2]
There are 2 contiguous groups of m = 3 servers: [1, 3, 2] and [3, 2, 1]. The k = 2ndnd lowest vulnerability in each group is 2. Return the answers for each group, in order: [2, 2].
02 Β· Example 2
k = 3
m = 4
vulnerability = [4, 2, 3, 1, 1]
return = [3, 2]
No explanation's found so far. If you happen to know about it. You're more than welcome to lmk! Many thanks in advance! 🧑
Constraints
  • 1 <= k <= m <= n <= 3*10^5
  • 1 <= vulnerability[i] <= 10^9
  • More Amazon problems
    drafts saved locally
    public int[] findKthMinimumVulnerability(int k, int m, int[] vulnerability) {
      // write your code here
    }
    
    k2
    m3
    vulnerability[1, 3, 2, 1]
    expected[2, 2]
    sign in to submit