You are viewing a single comment's thread. Return to all comments →
int height = 0; int i = 0; while(i<=n) { height = i % 2 ==0 ? height + 1 : height * 2; i++; } return height;
def one_cycle(height_one): return (2*height_one +1)
def utopianTree(n): # Write your code here height=1
cycles=n//2 if cycles: for i in range (cycles): height=one_cycle(height) if n%2==0: return height else: return (2*height)
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Utopian Tree
You are viewing a single comment's thread. Return to all comments →
def one_cycle(height_one): return (2*height_one +1)
def utopianTree(n): # Write your code here height=1