Hackerrank – Utopian Tree

Problem Statement
A description of the problem can be found on Hackerrank.

Solution
Make a height and initialize its value as 1. For each input number: if it is even double the height if it odd add 1 to height.

I created solution in:

All solutions are also available on my GitHub.

Java

JavaScript

Scala

Ruby