Created
September 7, 2022 07:36
-
-
Save piusayowale/e2074d1ef578a23a3becb30ff1237fa3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int utopianTree(int n) { | |
| int res = 0; | |
| int rem = 0; | |
| for(int i = 0; i <= n; i++){ | |
| if(rem == 0 && i > 0){ | |
| res = res * 2; | |
| }else{ | |
| res = res + 1; | |
| } | |
| int mod = i % 2; | |
| rem = mod; | |
| } | |
| return res; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment