We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Implementation
- Utopian Tree
- Discussions
Utopian Tree
Utopian Tree
Sort by
recency
|
1964 Discussions
|
Please Login in order to post a comment
python
count=0 for i in range(n+1): if i==0: count+=1 elif i%2==0 or i==1: count+=1 elif i%2==1: count*=2
return count
In C#
Go Solution
C# * int height = 0; if (n == 0) height = 1; else { for (int i = 1; i <= n; i++) { if (i % 2 == 0) height = height + 1; else height = height > 0 ? height * 2: i * 2;
} return height;