Leetcode 2509. Cycle Length Queries in a Tree
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.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.