FastPrepKth Largest Element in an Array
Problems/Kth Largest Element in an Array

Kth Largest Element in an Array

Nutanix logoNutanix● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This was one of the coding questions in a Nutanix infrastructure intern's phone screens in early 2020. The report names it only by a coded problem number, which reads as the classic task of finding the kth largest number in an array. The interviewer then asked whether the work could be split across several threads.

The report gives no statement, limits or examples. Here repeated values each count as their own place. k is from 1 to the array length. The array has at most 10^4 values between -10^4 and 10^4. The examples are our own. The threads follow-up is discussed in the editorial and is not tested.

Our version is about 80% the same as the reported question.

You are given an integer array nums and an integer k. Return the kth largest value in nums.

Repeated values each take their own place. Put all the values in order from largest to smallest, keeping repeats, and return the value in place k (counting from 1). For example, in [5, 5, 4] the 1st and 2nd largest values are both 5, and the 3rd largest is 4.

Follow-up from the interview: could the work be split across several threads? The judge does not test this; the editorial discusses it.

Function

findKthLargest(nums: int[], k: int) → int

Examples

Example 1

nums = [7,2,9,4,9,1]k = 2return = 9

From largest to smallest the values are 9, 9, 7, 4, 2, 1. The 2nd one is 9. Both 9s count, so the answer is not 7.

Example 2

nums = [3,-1,3,0]k = 4return = -1

From largest to smallest the values are 3, 3, 0, -1. With k equal to the length, the answer is the smallest value, -1.

Example 3

nums = [-5,-2,-8,-2,-3]k = 3return = -3

From largest to smallest the values are -2, -2, -3, -5, -8. The 3rd one is -3.

Constraints

  • 1 <= k <= nums.length <= 10^4
  • -10^4 <= nums[i] <= 10^4

More Nutanix Phone Screen questions

  • Swap Adjacent Linked List NodesPHONE SCREEN · Seen Mar 2025
  • Top K Most Frequent ValuesPHONE SCREEN · Seen Mar 2025
  • Unique Triplets Summing to ZeroPHONE SCREEN · Seen Sep 2024
  • Find the Duplicate in a Read-Only ArrayPHONE SCREEN · Seen Apr 2021
  • Kth Smallest Element in a BSTPHONE SCREEN · Seen Feb 2020
  • Outline of a Binary TreePHONE SCREEN · Seen Jan 2020
  • Print All File and Folder PathsPHONE SCREEN · Seen Dec 2019
  • Inorder Predecessor in a BSTPHONE SCREEN · Seen Jan 2019
  • K Largest and K Smallest ValuesPHONE SCREEN · Seen Jan 2019
  • Odd Numbers Up and BackPHONE SCREEN · Seen Jan 2019

Similar questions at other companies

  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
  • Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Select the Top User MatchesDuolingo · PHONE SCREENDuolingo interview questions
  • Meeting Rooms IIQuince · PHONE SCREENQuince interview questions
  • Kth Largest Element in an ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
  • Meeting Rooms IISecuronix · PHONE SCREEN
  • Merge Multiple Sorted StreamsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions

Interview reports that mention this question

  • Nutanix SWE Intern Phone Screens: 20 Experiences (Part 3 of 3)

Nutanix interview experiences

  • Nutanix SWE Intern OA Questions: 16 Experiences (Part 2 of 3)
  • Nutanix U.S. SWE Intern Interviews: 54 Experiences (Part 1 of 3)
  • Nutanix SWE OA and Interviews, Level Not Reported: 9 Experiences
  • Nutanix Intern Debugging Round and Interviews: 25 Experiences
All Nutanix interview questionsSee Nutanix hiring insights
Saved
class Solution {
    public int findKthLargest(int[] nums, int k) {
        // Write your code here.
    }
}
Checking account…