Problem Solving with Algorithms

반응형

leetcode.com/contest/weekly-contest-219

 

 

leetcode.com/problems/count-of-matches-in-tournament/

 

 

class Solution {
    public int numberOfMatches(int n) {
        int round = 0;
        while(n != 1) {
            round += n/2;
            n = n/2+n%2;
        }
        return round;
    }
}

 

빵터짐 ㅋㅋ

 

 

 

 

leetcode.com/problems/count-of-matches-in-tournament/

 

class Solution {
    public int minPartitions(String n) {
        int maximum = 0;
        for(int i = 0; i < n.length(); i++) {
            maximum = Math.max(maximum, n.charAt(i)-'0');
            if(maximum == 9) return 9;
        }
        return maximum;
    }
}

 

 

 

 

leetcode.com/problems/stone-game-vii/

이 문제는 돌게임에서 다루겠다.

 

 

 

 

 

leetcode.com/problems/maximum-height-by-stacking-cuboids/

이건 생각해볼 시간도 없었다...

반응형
반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band