PracHub
QuestionsCoachesLearningGuidesInterview Prep

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.

Validate Parentheses

Return whether a bracket string is valid.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ('()[]{}',)

Expected Output: True

Explanation: Valid mixed brackets.

Input: ('([)]',)

Expected Output: False

Explanation: Wrong nesting.

Input: ('(((',)

Expected Output: False

Explanation: Unclosed openings.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.

Kth Largest Element

Return the kth largest array element, counting duplicates separately, using a min-heap of size k.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([3,2,1,5,6,4], 2)

Expected Output: 5

Explanation: Second largest is 5.

Input: ([3,2,3,1,2,4,5,5,6], 4)

Expected Output: 4

Explanation: Duplicates count separately.

Input: ([1], 1)

Expected Output: 1

Explanation: Single element is the first largest.

Hints

  1. Clarify edge cases before coding.
  2. Keep the return value deterministic.
Last updated: Jun 27, 2026

Loading coding console...

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
  • AI Coding 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.

Related Coding 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)