PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Find the k-th largest element

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's understanding of selection algorithms and array manipulation, focusing on order statistics and correct handling of duplicates in an unsorted integer array.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Find the k-th largest element

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem Given an integer array `nums` and an integer `k`, return the **k-th largest** element in the array. Notes: - “k-th largest” means the element that would appear at index `k-1` if the array were sorted in **descending** order. - You must handle duplicates correctly (e.g., `[5,5,4]`, `k=2` → answer `5`). ## Input - `nums`: array of integers - `k`: integer where `1 <= k <= len(nums)` ## Output - The k-th largest element (an integer). ## Constraints (typical interview scale) - `1 <= n <= 2 * 10^5` - `-10^9 <= nums[i] <= 10^9` ## Example - `nums = [3,2,1,5,6,4], k = 2` → answer `5`

Quick Answer: This question evaluates a candidate's understanding of selection algorithms and array manipulation, focusing on order statistics and correct handling of duplicates in an unsorted integer array.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
Meta logo
Meta
Oct 23, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
1
0

Problem

Given an integer array nums and an integer k, return the k-th largest element in the array.

Notes:

  • “k-th largest” means the element that would appear at index k-1 if the array were sorted in descending order.
  • You must handle duplicates correctly (e.g., [5,5,4] , k=2 → answer 5 ).

Input

  • nums : array of integers
  • k : integer where 1 <= k <= len(nums)

Output

  • The k-th largest element (an integer).

Constraints (typical interview scale)

  • 1 <= n <= 2 * 10^5
  • -10^9 <= nums[i] <= 10^9

Example

  • nums = [3,2,1,5,6,4], k = 2 → answer 5

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.