public int[] animals(int heads, int legs) {
		int chicken = 0;
		int cow = 0;
		for (; heads > 0; heads--) {
			if (legs / 2 > heads) {
				legs -= 4;
				cow++;
			} else {
				legs -= 2;
				chicken++;
			}
		}
		if (legs == 0) {
			return new int[] { chicken, cow };
		}
		return new int[] {};
	}