• + 0 comments

    JAVA

    public static int utopianTree(int n) {

    int h=0;
    
    for(int i=0;i<=n;i++){
    
        if(i%2==0){
    
            h++;
    
        }else h*=2;
    }
    return h;
    }