• + 0 comments

    My Java solution with o(1) time complexity and o(1) space:

    public static int towerBreakers(int n, int m) {
            if(m == 1 || n % 2 == 0) return 2;
            else return 1;
        }