We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Implementation
- Utopian Tree
- Discussions
Utopian Tree
Utopian Tree
Sort by
recency
|
1970 Discussions
|
Please Login in order to post a comment
Hi there! Here's my Java solution for the challenge.
https://github.com/eduardocintra/hacker-rank-solutions/blob/master/src/br/com/eduardocintra/easy/utopiantree/UtopianTree.java
Solution in C
Javascript solution: Loop until the n finding the Even numbers and multiply the current tree height by 2 else add 1 for the tree height
Java Solution
Here's my solutions in python:
Tested when n =
1000
Solution 1: Average(961 ns)
Solution 2: Average(138 µs):
Solution 3: More readable version of the first solution Average(1.47 µs):