• + 1 comment
    int height = 0;
        int i = 0;
        while(i<=n) {
            height = i % 2 ==0 ? height + 1 : height * 2;
            i++;
        }
        return height;
    
    • + 0 comments

      def one_cycle(height_one): return (2*height_one +1)

      def utopianTree(n): # Write your code here height=1

          cycles=n//2    
      
      if cycles:
          for i in range (cycles):
              height=one_cycle(height) 
      if n%2==0:
          return height
      else: 
      
          return (2*height)