there is a bridge next to an old train station whose bridge deck can be rotated horizontally around the pier in the center of the river. staff of the station found that the length of the bridge can accommodate up to two carriages. if the bridge is rotated 180 degrees, the positions of two adjacent carriages can be exchanged. in this way, the order of the carriages can be arranged. so he was responsible for using the bridge to rearrange the unsorted carriages from small to large numbers. after he retired, the train station decided to automate this work. one of the important tasks was to make a program, to take the numbers of the initial order of carriage, and calculate the minimum number of steps needed to sort the carriages.



Answer :

Other Questions