public static boolean either24(int[] nums) {
        boolean is = false;
        boolean was2 = false;
        boolean was4 = false;
        boolean twice2 = false;
        boolean twice4 = false;

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 2) {
                if (was2)
                    twice2 = true;
                else
                    was2 = true;
            }
            else if (nums[i] == 4) {
                if (was4)
                    twice4 = true;
                else
                    was4 = true;
            }
            else {
                was2 = false;
                was4 = false;
            }
        }

        if (twice2 ^ twice4)
            is = true;

        return is;
    }