Get count of longest zigzag sub-sequences
Extending the well-known dynamic programming algorithm for Longest Common Subsesequence, we have a poly-time algorithm for Longest Zig-zag Subsequence.

When DPing, just also add another parameter: $\mathrm{A}[\mathrm{i}][\mathrm{j}]$ is the length of the longest zig-zag sequence ending at position $i$ and it is increasing when it ends at $i$ if $j = 0$ and otherwise, decreasing when it ends at $i$ if $j = 1$. So, at a position $i$, you scan from $1$ to $i-1$ and update $\mathrm{A}[\mathrm{i}][\mathrm{0}]$ and $\mathrm{A}[\mathrm{i}][\mathrm{1}]$ gradually. Note that you need to make the $\mathrm{j}$-index alternate while updating.