Codility: TreeHeight

Fredric Cliver
Sep 19, 2021

--

Photo by veeterzy on Unsplash

Test Page: https://app.codility.com/programmers/trainings/4/tree_height/

Solution

Explains

  1. On the first node, fire the ‘calculate’ method, and it goes to repeat until the child node hasn’t any child node of itself.
  2. On the progress, the ‘max’ variable is contained on the ‘calculate’ method, and it is going to be incremented when it has any child.
  3. The max parameter is received as ‘inout’ parameter, so when it has been updated, the change is not saved local on the method, it’s going to be updated on the top (at the solution method)

Evaluation

--

--

Fredric Cliver
Fredric Cliver

Written by Fredric Cliver

13+ years in the digital trenches. I decode complex tech concepts into actionable insights, focusing on AI, Software Engineering, and emerging technologies.

No responses yet