PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates binary tree traversal and view-extraction skills for the right-side view problem and string-processing and minimal-edit balancing for the parentheses cleanup, probing competency in data-structure traversal, state tracking, and correctness under edge cases.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve tree view and parentheses cleanup

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Solve the following two algorithm problems. 1. Right-side view of a binary tree Given the root of a binary tree, return the values of the nodes that would be visible if you looked at the tree from its right side, listed from top to bottom. Example: - Input: root = [1,2,3,null,5,null,4] - Output: [1,3,4] 2. Remove the minimum invalid parentheses Given a string `s` containing lowercase English letters and the characters `(` and `)`, remove the minimum number of parentheses so that the resulting string is valid. A string is valid if: - every opening parenthesis has a matching closing parenthesis, - parentheses are properly ordered, - letters may appear anywhere and do not affect validity. Return any valid string after the minimum removals. Examples: - Input: `a)b(c)d` Output: `ab(c)d` - Input: `))( (` Output: `` - Input: `(a(b(c)d)` Output: `a(b(c)d)`

Quick Answer: This question evaluates binary tree traversal and view-extraction skills for the right-side view problem and string-processing and minimal-edit balancing for the parentheses cleanup, probing competency in data-structure traversal, state tracking, and correctness under edge cases.

Right-Side View of a Binary Tree

Given level-order tree values, return the values visible from the right side.

Constraints

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

Examples

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

Expected Output: [1, 3, 4]

Explanation: Prompt example.

Input: ([],)

Expected Output: []

Explanation: Empty tree.

Input: ([1,2,None,3],)

Expected Output: [1, 2, 3]

Explanation: Left skew.

Hints

  1. Model object-style prompts as arrays or operation streams when needed.
  2. Handle empty and boundary cases before the main logic.

Remove Minimum Invalid Parentheses

Remove the minimum number of parentheses so the remaining string is valid.

Constraints

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

Examples

Input: ('a)b(c)d',)

Expected Output: 'ab(c)d'

Explanation: Prompt example.

Input: ('))((',)

Expected Output: ''

Explanation: Remove all invalid parens.

Input: ('(a(b(c)d)',)

Expected Output: 'a(b(c)d)'

Explanation: Prompt-style unmatched open.

Hints

  1. Model object-style prompts as arrays or operation streams when needed.
  2. Handle empty and boundary cases before the main logic.
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)