Databricks interview question

Difficult problem with fibonacci trees