You own a large selection of DVDs that you and your friends enjoy. Unfortunately, your friends aren't the most considerate bunch, so each DVD is not necessarily returned to its respective case. When your friends want to watch a movie, they go through each of your DVD cases one by one until they find the movie they want to watch. They then take that DVD out, and switch it with the one that's currently in the player.
You will be given a String[] moviesWatched: a list of all the movies watched in an unspecified time period, in the order they were watched. Assume you only own one copy of each movie. The DVD player is initially empty, and each DVD starts in its own case. You should return a String[] where each element describes a movie that is in a different movie's case after all DVDs in moviesWatched have been viewed. These elements should be of the format "<movie1> is inside <movie2>'s case". The list should be ordered alphabetically by the title of <movie1>. The last DVD in moviesWatched will still be in the DVD player at the end of the simulation, so it should never appear as <movie1> in the returned list. |