PracHub
QuestionsLearningGuidesInterview Prep

Quick Overview

Practice a Google coding interview problem focused on find the longest consecutive path in a binary tree. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

  • medium
  • Google
  • Coding & Algorithms
  • Software Engineer

Find the Longest Consecutive Path in a Binary Tree

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Given a binary tree, return the length of the longest downward path where each child value is exactly one greater than its parent value. Nodes have `val`, `left`, and `right`. Implement: ```python def longest_downward_consecutive_path(root) -> int: pass ```

Quick Answer: Practice a Google coding interview problem focused on find the longest consecutive path in a binary tree. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Given a serialized binary tree `[val,left,right]`, return the longest downward parent-to-child path where values increase by one.

Examples

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

Expected Output: 2

Explanation: 1->2 or 1->3? only 1->2.

Input: (None,)

Expected Output: 0

Explanation: Empty.

Last updated: Jul 4, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

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

  • Count Overlapping Rectangle Updates on a Grid - Google (hard)
  • Find A Threshold-Limited Path With Minimum Required Safety - Google (medium)
  • Filter Repeated Robot Status Messages - Google (medium)
  • Minimize Direction Violations in a Directed Road Network - Google (medium)
  • Find the Largest Monotone Increasing Number - Google (medium)