Sponsored
Sponsored
Solve with full IDE support and test cases
Use these hints if you're stuck. Try solving on your own first.
The possible sequence either contains all even elements, all odd elements, alternate even odd, or alternate odd even elements.
Considering only the parity of elements, there are only 4 possibilities and we can try all of them.
When selecting an element with any parity, try to select the earliest one.