DOCUSIGN Coding Question – Solved

5 Live
Hackerrank developers want to deploy an application on a set of exactly k servers with different vulnerabilities. They have an option to choose the k servers from a sequence of n servers where vulnerability[i] represents the vulnerability of the ith server. The vulnerability of the chosen k servers is defined as the maximum vulnerability amongst any of the chosen servers. To avoid congestion, they would like to choose a subsequence of k servers such that no two adjacent servers are chosen as part of the k servers. Given an array vulnerability and an integer k, find the minimum possible vulnerability of the chosen servers such that the above condition is respected. Example Given n = 4, k = 2 and vulnerability = [2, 3, 5, 9], only 3 subsequences of k = 2 non-adjacent servers exist: [2, 5] - max = 5 [3, 9] - max = 9 [2, 9] - max = 9 Report 5 as the answer. Function Description Complete the function getMinVulnerability in the editor below. getMinVulnerability has the following parameters: int vulnerability[n]: An array of integers int k: the length of the subsequences to form Returns int: the minimum value returned by the max function for all valid subsequences Constraints 1 <= n <= 10^5 1 <= k <= (n + 1) / 2

Asked in: DOCUSIGN

Image of the Question

Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |