Deciding if two arrays would generate the same BST