PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Validate parentheses and find k-th largest

Last updated: Mar 29, 2026

Quick Overview

This pair of problems evaluates mastery of fundamental data structures and algorithmic techniques: Problem A tests understanding of stack-based parsing and bracket-matching invariants for validating nested delimiters, while Problem B assesses proficiency with selection algorithms and heap-based priority queues for finding the k-th largest element.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Validate parentheses and find k-th largest

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem A — Validate parentheses Given a string `s` containing only the characters `'('`, `')'`, `'['`, `']'`, `'{'`, `'}'`, determine whether the input string is **valid**. A string is valid if: - Open brackets are closed by the **same type** of brackets. - Open brackets are closed in the **correct order**. - Every closing bracket has a corresponding previously-opened bracket. **Input:** `s` (string) **Output:** `true` if `s` is valid, otherwise `false`. **Example** - `s = "()[]{}"` → `true` - `s = "([)]"` → `false` **Constraints (typical):** `1 <= |s| <= 10^4` --- ## Problem B — k-th largest element using a heap Given an integer array `nums` and an integer `k`, return the **k-th largest** element in the array. Notes: - “k-th largest” refers to the element that would appear at index `k-1` if the array were sorted in descending order. - Duplicates count as separate elements. **Input:** `nums` (array of integers), `k` (integer) **Output:** an integer, the k-th largest element. **Example** - `nums = [3,2,1,5,6,4], k = 2` → `5` **Constraints (typical):** - `1 <= n <= 10^5` - `1 <= k <= n` - `nums[i]` fits in 32-bit signed int

Quick Answer: This pair of problems evaluates mastery of fundamental data structures and algorithmic techniques: Problem A tests understanding of stack-based parsing and bracket-matching invariants for validating nested delimiters, while Problem B assesses proficiency with selection algorithms and heap-based priority queues for finding the k-th largest element.

Related Interview Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
Meta logo
Meta
Jan 6, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
5
0
Loading...

Problem A — Validate parentheses

Given a string s containing only the characters '(', ')', '[', ']', '{', '}', determine whether the input string is valid.

A string is valid if:

  • Open brackets are closed by the same type of brackets.
  • Open brackets are closed in the correct order .
  • Every closing bracket has a corresponding previously-opened bracket.

Input: s (string)

Output: true if s is valid, otherwise false.

Example

  • s = "()[]{}" → true
  • s = "([)]" → false

Constraints (typical): 1 <= |s| <= 10^4

Problem B — k-th largest element using a heap

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

Notes:

  • “k-th largest” refers to the element that would appear at index k-1 if the array were sorted in descending order.
  • Duplicates count as separate elements.

Input: nums (array of integers), k (integer)

Output: an integer, the k-th largest element.

Example

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

Constraints (typical):

  • 1 <= n <= 10^5
  • 1 <= k <= n
  • nums[i] fits in 32-bit signed int

Submit Your Answer to Earn 20XP

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,000+ 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.