FastPrepK-th Largest Value in an Array
Problems/K-th Largest Value in an Array

K-th Largest Value in an Array

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem returns the value that ranks k-th when an array is ordered from largest to smallest. A post by a CS 1 candidate in Noida, India, then an SDE 2 at a product company (posted September 2023, rejected), links this classic task as the second question of the first of two one-hour rounds. Before it came some security and networking terms and a short math question, and a puzzle came after. The author reports giving a simple approach first and then one based on a heap. The post gives no limits or examples.

The rules here are those of the linked task, so equal values each count. Our choices: up to 10^4 values from -10^4 to 10^4, and new examples. We check only the returned value, so a full sort also passes. The editorial covers both the sort and the heap.

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

You are given an integer array nums and an integer k. Return the k-th largest value in the array: the value that would sit at position k if the array were sorted from largest to smallest, with position 1 holding the largest value.

Equal values each take their own position, so the answer is not the k-th largest distinct value. For example, in [8,8,3] the second largest value is 8.

Function

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

Examples

Example 1

nums = [7,-2,15,4,9,4]k = 3return = 7

From largest to smallest the values are 15, 9, 7, 4, 4, -2. The third one is 7.

Example 2

nums = [8,8,3,8,1]k = 2return = 8

Equal values each count: from largest to smallest the values are 8, 8, 8, 3, 1, so the second largest is 8, not 3.

Example 3

nums = [-5]k = 1return = -5

One value: it is the largest. Answer: -5.

Constraints

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

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

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

  • Adobe Frontend and QA Interviews: 14 Experiences (Part 6 of 6)
  • Adobe CS1 Interviews: 14 Experiences (Part 4 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int kthLargest(int[] nums, int k) {
        // Write your code here.
    }
}
Checking account…