Skip to content

Instantly share code, notes, and snippets.

@piusayowale
Created September 7, 2022 07:36
Show Gist options
  • Select an option

  • Save piusayowale/e2074d1ef578a23a3becb30ff1237fa3 to your computer and use it in GitHub Desktop.

Select an option

Save piusayowale/e2074d1ef578a23a3becb30ff1237fa3 to your computer and use it in GitHub Desktop.
int utopianTree(int n) {
int res = 0;
int rem = 0;
for(int i = 0; i <= n; i++){
if(rem == 0 && i > 0){
res = res * 2;
}else{
res = res + 1;
}
int mod = i % 2;
rem = mod;
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment