← 返回 databricks 的题目列表Fibonacci Tree Two Nodes Path (Preorder Index)
类型:online_judge
Problem Statement: Given a k-th Fibonacci tree where the left subtree is F(k-2) and the right subtree is F(k-1), and nodes are numbered using preorder starting from root=0, find the path between two nodes with given ids a and b.
Implement the function find_path(k, a, b).
Input:
k: The Fibonacci order of the node.
a, b: Node indices.
Output:
A list of node indexes representing the path from a to b.
Example
Input
5 3 7
Output
[3, 0, 2, 7]