PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers
|Home/Coding & Algorithms/Snowflake

Compute height after deletions; enumerate valid delete sets

Last updated: Mar 29, 2026

Quick Overview

This question evaluates competence in binary tree manipulation and combinatorial search, covering promotion-based node deletion, height computation across forest components after root deletion, enumeration of deletion sets with deduplication, pruning strategies, and time/space complexity analysis.

  • Medium
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Compute height after deletions; enumerate valid delete sets

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Warm-up: You are given a rooted binary tree with unique node ids and a list of ids to delete. When a node is deleted, promote all of its children to become children of the deleted node’s parent (preserving left/right positions when possible; if only one child exists, it occupies the appropriate side). After applying all deletions, compute the number of levels in the resulting tree. State and handle the case where the root is deleted (e.g., produce a forest and return the maximum height across the components) and analyze time/space complexity. Main: With the same promotion rule, you are given a rooted binary tree, an integer n (maximum deletions allowed), and a target height k. Return all unique sets of node ids whose deletion yields a tree whose height is exactly k using at most n deletions. Output each set as a sorted list of ids; avoid duplicates. Describe your search/pruning strategy, correctness argument, and complexity.

Quick Answer: This question evaluates competence in binary tree manipulation and combinatorial search, covering promotion-based node deletion, height computation across forest components after root deletion, enumeration of deletion sets with deduplication, pruning strategies, and time/space complexity analysis.

Related Interview Questions

  • Implement Document Predicate APIs - Snowflake (medium)
  • Find Shortest Wiki Click Path - Snowflake (medium)
  • Schedule prerequisite classes with retakes - Snowflake (easy)
  • Solve three coding rounds - Snowflake (medium)
  • Minimize coins with overpay and change - Snowflake (hard)
Snowflake logo
Snowflake
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
8
0

Warm-up: You are given a rooted binary tree with unique node ids and a list of ids to delete. When a node is deleted, promote all of its children to become children of the deleted node’s parent (preserving left/right positions when possible; if only one child exists, it occupies the appropriate side). After applying all deletions, compute the number of levels in the resulting tree. State and handle the case where the root is deleted (e.g., produce a forest and return the maximum height across the components) and analyze time/space complexity. Main: With the same promotion rule, you are given a rooted binary tree, an integer n (maximum deletions allowed), and a target height k. Return all unique sets of node ids whose deletion yields a tree whose height is exactly k using at most n deletions. Output each set as a sorted list of ids; avoid duplicates. Describe your search/pruning strategy, correctness argument, and complexity.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snowflake•More Software Engineer•Snowflake Software Engineer•Snowflake 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
  • Careers
  • 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.