PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Implement tree column grouping and minimal parentheses fixes

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in tree and string algorithms, specifically binary tree traversal and coordinate-based column grouping with ordering/tie-breaking semantics, as well as string processing for minimal-parentheses deletion, and probes competence with data structures, streaming/online processing, correctness guarantees, and in-place space management. It is commonly asked in the Coding & Algorithms domain to assess algorithmic reasoning, implementation-level trade-offs and complexity analysis, testing both conceptual understanding of ordering and correctness and practical application skills such as achieving linear-time and space-efficient solutions and scaling to large inputs.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Implement tree column grouping and minimal parentheses fixes

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

Part A — Binary tree column grouping: Given the root of a binary tree, group node values by their vertical columns from leftmost to rightmost using x-coordinates (left child: x-1, right child: x+ 1). Within each column, list nodes in top-to-bottom order; if two nodes share the same row and column, order them by left-to-right encounter. Return a list of columns (each a list of integers). Describe your algorithm, the data structures used, and analyze time and space complexity. Follow-ups: ( 1) How would you stream results without storing the entire traversal? ( 2) How would you change tie-breaking to use node values instead? ( 3) Discuss handling trees with up to 100,000 nodes. Part B — Minimal deletions for balanced parentheses: Given a string s of lowercase letters and parentheses '()' only, remove the fewest parentheses so the string is balanced. Return any valid resulting string. Provide an O(n) time solution and prove correctness. Follow-ups: ( 1) Can you do it in a single pass? ( 2) Can you achieve O( 1) extra space if in-place edits are allowed?)

Quick Answer: This question evaluates proficiency in tree and string algorithms, specifically binary tree traversal and coordinate-based column grouping with ordering/tie-breaking semantics, as well as string processing for minimal-parentheses deletion, and probes competence with data structures, streaming/online processing, correctness guarantees, and in-place space management. It is commonly asked in the Coding & Algorithms domain to assess algorithmic reasoning, implementation-level trade-offs and complexity analysis, testing both conceptual understanding of ordering and correctness and practical application skills such as achieving linear-time and space-efficient solutions and scaling to large inputs.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)
Meta logo
Meta
Aug 13, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
1
0

Part A — Binary tree column grouping: Given the root of a binary tree, group node values by their vertical columns from leftmost to rightmost using x-coordinates (left child: x-1, right child: x+ 1). Within each column, list nodes in top-to-bottom order; if two nodes share the same row and column, order them by left-to-right encounter. Return a list of columns (each a list of integers). Describe your algorithm, the data structures used, and analyze time and space complexity. Follow-ups: (

  1. How would you stream results without storing the entire traversal? (
  2. How would you change tie-breaking to use node values instead? (
  3. Discuss handling trees with up to 100,000 nodes.

Part B — Minimal deletions for balanced parentheses: Given a string s of lowercase letters and parentheses '()' only, remove the fewest parentheses so the string is balanced. Return any valid resulting string. Provide an O(n) time solution and prove correctness. Follow-ups: (

  1. Can you do it in a single pass? (
  2. Can you achieve O(
  3. extra space if in-place edits are allowed?)

Comments (0)

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