Databricks Interview Question

Difficult problem with fibonacci trees