I've been stuck on the following problem which I've been trying to do recursively.
Let n be a positive integer. Consider all permutations of $\{1, 2, \dots , n \}$. Let $A_n$ denote the set of those permutations such that each number is either greater than all of the numbers to its left or less than all of the numbers to its right. Let $B_n$ denote the set of those permutations $a_1,\dots a_n$ such that for $1 \leq i \leq n-1$, there is a $j > i$ with $|a_j -a_i| = 1$. Show that $|A_n| = |B_n|$.
I've been trying to do this recursively by showing there's the same recursion on $|A_n|$ and $|B_n|$ but I haven't been able to go anywhere. My first thought was that $|A_n| = n|A_{n-1}|$ because $n$ can be in any position of the permutation; $n$ can be in any position because it's always greater than the elements to it's left. But this recursion would lead to $|A_n| = n!$ which is clearly not true. However I don't see what I'm missing here, so any help would be appreciated.
Only half an answer but too long for a comment.
$|A|=2^n-n$
A “good” permutation is a set of numbers you select, written in ascending order, followed by the numbers you didn’t select, also in ascending order.
Each number selection corresponds to a unique good permutation except that selections $\{\}$, 1, 12, 123, etc all correspond to the same permutation (the super-good one, where everything is in one ascending sequence).
Selectedness is a yes-or-no decision, so there are $2^n$ possible selections. The supergood permutation corresponds to $n+1$ selections, so we have to subtract $n$ from this total.
You can verify this by hand for values of $n$ from 4 down to 1. Or even 0 if you want.