dp: compute all permutation of a string