Back to problems

Find K-th Largest and Longest Vacation

Algorithm · Meta · Medium

Problem 1 Given an integer array nums and a zero-based rank k, find the value that would occupy position k after sorting nums in non-increasing order. In other words, k = 0 asks for the largest value, k = 1 asks for the second-largest, and so on. Duplicate values remain in the sorted result. Return this value as a single integer. Example 1: Explanation: After sorting as [8, 7, 4, 2, 0], the value at index 2 is 4. Example 2: Explanation: After sorting as [11, 11, 3, -1],…

Checking your access…