PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates string-processing and tree-traversal algorithm skills, focusing on efficient group-deletion and streaming-capable string dedup operations and a mirrored boundary traversal of binary trees, and it tests algorithmic design, complexity guarantees, and correctness/termination reasoning.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Implement string dedup and mirror tree traversal

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

- String cleanup with group deletions (LeetCode-inspired): Given a string s consisting of lowercase letters, repeatedly delete any maximal contiguous group of two or more identical characters (e.g., "abbbaaccz" -> remove "bbb" and "aa" -> "ccz" -> remove "cc" -> "z"). Return the final string after all deletions. Design an O(n) time, O(n) space solution and explain why it terminates and is correct. Follow-up: support a parameter k >= 2 to delete any group whose length is at least k; and support streaming input where characters arrive one by one. - Mirror boundary traversal of a binary tree (LeetCode-inspired): Given the root of a binary tree, output a "mirror boundary" list constructed as follows: ( 1) take the left boundary nodes (excluding the root) from the deepest leftmost leaf up to root.left (bottom-up); ( 2) then include root; ( 3) then take the right boundary nodes (excluding the root) from root.right down to the deepest rightmost leaf (top-down). Do not list any node more than once; if a node is both on a boundary and a leaf, include it once. Return the resulting list of node values. Provide an algorithm with time O(n) and space O(h), where h is the tree height.

Quick Answer: This question evaluates string-processing and tree-traversal algorithm skills, focusing on efficient group-deletion and streaming-capable string dedup operations and a mirrored boundary traversal of binary trees, and it tests algorithmic design, complexity guarantees, and correctness/termination reasoning.

String Cleanup By Group Deletions

Repeatedly delete groups whose length is at least k and return the final string.

Constraints

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

Examples

Input: ('abbbaaccz', 2)

Expected Output: 'abz'

Explanation: Cascading deletions leave z.

Input: ('deeedbbcccbdaa', 3)

Expected Output: 'aa'

Explanation: k=3 deletion variant.

Input: ('abc', 2)

Expected Output: 'abc'

Explanation: No deletions.

Hints

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

Mirror Boundary Traversal

Trees are [value,left,right]. Return left boundary bottom-up, root, and right boundary top-down without duplicates.

Constraints

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

Examples

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

Expected Output: [4, 2, 1, 3, 6]

Explanation: Left boundary bottom-up, root, then right boundary top-down.

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

Expected Output: [1]

Explanation: Single root appears once.

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)