In this challenge Bubbler describes sorting a list by inserting its elements left to right into a double ended queue or "deque".
Take a number from the front of the array, and push it into one of the two ends of the deque. Repeat this until the array is empty.
That challenge asks if it is possible to sort a given array using this procedure. That is it possible to choose a pattern of fronts and backs which yields a sorted deque at the end.
In this challenge we ask whether it is possible to do sort a list by following this procedure twice. That is:
Take a number from the front of the array, and push it into one of the two ends of the deque. Repeat this until the array is empty.
Then take a number from the front of that deque and push it into one of the two ends of a new deque. Repeat this until the first deque is empty.
For example the list [4,5,6,1,2,3] cannot be sorted using one pass of this procedure. However with one pass we can get the list [3,2,1,4,5,6] which can be sorted with another pass.
Not all lists can be sorted in two passes however. For example [5,3,4,1,2] requires a minimum of 3 passes to sort.
Task
Given an array of positive integers determine if it can be sorted in two passes of the procedure. Output one of two distinct consistent values depending on whether the input is possible or impossible to sort in two passes.
This is code-golf. The goal is to minimize the size of your source code as measured in bytes.
Test cases
Possible
[1]
[1,2,3,4]
[4,3,2,1]
[10,10,10,10]
[3,4,2,5,1,6]
[4,3,5,2,6,1]
[5,4,4,5,3,5,3,6,2,6]
[1,3,2]
[3,4,5,1,2,3]
Impossible
[5,3,4,1,2]
[7,5,6,3,4,1,2]
[7,8,9,3,4,5,1,2,3]