Algorithm: optimal way to rearrange a list from one order to another?
问题 EDIT: I'm not sure that my original question is clear enough. I need an algorithm that will compute the minimal sequence of moves to rearrange an array from one order to another. It is known that both arrays will contain the same elements (no duplicates) and have the same length. For example: reorder( ['d', 'a', 'c', 'b', 'e'], ['a', 'b', 'c', 'd', 'e'] ) should return something like: [ {move:'d', after:'b'}, {move:'c', after:'b'} ] which indicates that I should first move the element 'd' to