You are viewing a single comment's thread. Return to all comments →
In java 8
public static int utopianTree(int n) { // Write your code here boolean isSpring = true; int height = 1;
for(int i = 1; i <= n; i++){ if(isSpring){ height = height * 2; isSpring = false; } else{ height++; isSpring =true; } } return height; }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Utopian Tree
You are viewing a single comment's thread. Return to all comments →
In java 8
public static int utopianTree(int n) { // Write your code here boolean isSpring = true;
int height = 1;
}