Company: Flipkart_2nov

Difficulty: medium

Problem Statement

Minimum Moves to Restore Robot Order Problem Description A city runs an annual parade featuring a troupe of autonomous robots. N robots take part, each uniquely numbered from 1 to N. At the start of the parade, the robots stand in perfect order (robot 1 through robot N, left to right). During rehearsal, someone tampered with the robots and issued a sequence of reordering commands. Each command is one of two kinds: Command Type A: A X Y - move robot X in front of robot Y Command Type B: B X Y - move robot X behind robot Y Being obedient machines, the robots carried out every command exactly as given. Now the parade is about to begin and the robots must be back in order from 1 to N, but the rehearsal log only records the final lineup and the commands that were issued - not where each robot started. Given N and M, the number of robots and the number of reordering commands that were issued, write a program that finds the minimum number of moves needed to bring the robots back into their or

More Flipkart_2nov OA questionsInterview experiences