package leetcode;

public class Problem1688 {
    public int numberOfMatches(int n) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1688 prob = new Problem1688();
        System.out.println(prob.numberOfMatches(7)); // 6
        System.out.println(prob.numberOfMatches(14)); // 13
    }
}

package leetcode;

public class Problem1688 {
    public int numberOfMatches(int n) {
        int answer = 0;
        int winner = n;
        while (winner >= 2) {
            int matches;
            if (winner % 2 == 0) {
                matches = winner / 2;
            } else {
                matches = (winner - 1) / 2;
            }
            winner -= matches;
            answer += matches;
        }
        return answer;
    }
}

Solve problem 1688