Available question text
Given a complete binary tree labeled 1..2^n-1, each query adds an edge between nodes a and b and asks for the length of the unique cycle created. The task reduces to computing the tree distance between a and b (via their LCA in the implicit heap-like tree where parent = floor(val/2)), then returning distance+1 for each query.
Related questions
Continue with questions that share topics or the same question type.
- Closest Nodes Queries in a Binary Search Tree
Coding
- Height of Binary Tree After Subtree Removal Queries
Coding
- Minimum Edge Weight Equilibrium Queries in a Tree
Coding
- All Nodes Distance K in Binary Tree
Coding · Binary Tree · Breadth-First Search · Depth-First Search
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2509. Cycle Length Queries in a Tree
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source