Solution to Tree-Height by codility

29 Jan


Question Name: TreeHeight

Classic recursion problem.

10 Replies to “Solution to Tree-Height by codility

  1. Java version:

    • Thanks for sharing your solution!
      For posting code, please add the code inside a <pre> </pre> section, rather than <code> </code>.
      BTW, the first Math.max is not necessary.

    • Or more simply

  2. Hi Guys! I thought about doing this solution too but isn’t this n^2 time complexity ?
    In the end the performance of my test was not assessed, but other solutions I tried before with recursion were always a bit slow.

  3. Quick solution in C# (left in some code that I refactored out)… 100%

  4. What is the problem for this? It says tree height but it doesn’t look like the tree height problem I had on the test. Which was to make the minimum number of cuts so that trees have heights going up and down alternately. If it is for that problem then I’m somewhat lost.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!