PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Snowflake

Compute shortest path between two tree nodes

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of tree algorithms and preprocessing techniques for efficient path queries, along with robustness in handling missing or duplicate node values and very deep trees.

  • Medium
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Compute shortest path between two tree nodes

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Given a binary tree (not necessarily a BST) and two node values u and v, implement a function that returns the shortest path between them as a list of node values. Optimize for multiple queries by describing preprocessing strategies (e.g., storing parent pointers, Euler tour + RMQ LCA, or binary lifting). Discuss time/space trade-offs and how to handle missing nodes, duplicate values, and very deep trees.

Quick Answer: This question evaluates understanding of tree algorithms and preprocessing techniques for efficient path queries, along with robustness in handling missing or duplicate node values and very deep trees.

Related Interview Questions

  • Solve Array Distance and Wiki Navigation - Snowflake (medium)
  • 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)
Snowflake logo
Snowflake
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
2
0

Given a binary tree (not necessarily a BST) and two node values u and v, implement a function that returns the shortest path between them as a list of node values. Optimize for multiple queries by describing preprocessing strategies (e.g., storing parent pointers, Euler tour + RMQ LCA, or binary lifting). Discuss time/space trade-offs and how to handle missing nodes, duplicate values, and very deep trees.

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