There are some people and cats in a house. You are given the number of legs they have all together. Your task is to return an array containing every possible number of people that could be in the house sorted in ascending order. It’s guaranteed that each person has
2 legs and each cat has
legs = 6, the output should be
houseOfCats(legs) = [1, 3].There could be either
4 + 2 = 6) or
2 * 3 = 6).
legs = 2, the output should be
houseOfCats(legs) = .There can be only
- [time limit] 4000ms (py)
- [input] integer legsThe total number of legs in the house.
0 ≤ legs ≤ 45.
- [output] array.integerEvery possible number of people that can be in the house.
if legs%4==2 or legs%4==0:
c = 1 if (legs%4) == 2 else 0