The problem:
Given a particular sequence of up to 50 integers, which represent nodes of a certain binary search tree (BST), how many permutations of this sequence are there, which will also give rise to exactly the same BST? Include the original sequence in your total count as 1 sequence.
For instance, answer = 6 for such a sequence [5,2,1,9,8]: [5,2,1,9,8] (itself, the original sequence given), [5,9,8,2,1], [5,2,9,1,8], [5,9,2,1,8], [5,2,9,8,1], [5,9,2,8,1]