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

'개발 > CodingTest' 카테고리의 다른 글

LeetCode - Min Stack  (0) 2020.06.26
LeetCode - Shuffle the array  (0) 2020.06.26
Hacckerrank - The Hurdle Race  (0) 2020.06.25
Hacckerrank - Halloween Sale  (0) 2020.06.25
Hackerrank - Prime Checker  (0) 2020.06.05
Posted by Lumasca
,