🎁 Exclusive Offer! Join our Telegram Channel to get **special discounts** and updates! 🚀

🚀 Struggling with coding interviews? We've got you covered! 💡 Practice real questions, sharpen your skills, and land your dream job! 🎯
Question 69 - 100% Working Solution | Buy Now

Description

7 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