A shipping line alternates between two loading bays, so the container ids should alternate between even and odd numbers. Return True if every pair of neighbours in ids has different parity (one even, one odd), else False. Lists with fewer than two ids are fine.
Examples
Input: ids = [2, 5, 8, 3]
Output: True
Input: ids = [2, 4, 5]
Output: False
Explanation: 2 and 4 are both even.
Constraints
0 <= len(ids) <= 10**5-10**9 <= ids[i] <= 10**9- Target: O(n) time.
Goals
- Compare a property of neighbouring elements rather than their values
- Short-circuit on the first violation