• + 0 comments

    C#

        public static int utopianTree(int n)
        {
            int height = 0;
            
            for(int i = 0; i <= n; i++){
                
                if (i % 2 == 0){
                    height++;
                }
                else{
                    height *= 2;
                }
                
            }
            
            return height;
        }