• + 0 comments

    solution 1: O(1) cpp solution--

    int utopianTree(int n) { int exponent=n/2 +1 +n%2; int result=pow(2,exponent); if(n%2==0){ return result-1; } else{ return result-2; } }