This is a problem 1.6 from the book Algorithm Design by Kleinberg/Tardos:
There's a company that manages ships that do various tasks when in port. There're $n$ ships, $n$ ports, $m$ days in a month such that $m>n$.
At any given day there can't be two ships from the company in the same port. $(*)$
The company wants to perform maintenance on all the ships this month, via the following scheme: they want to truncate each ship’s schedule: for each ship $S_i$, there will be some day when it arrives in its scheduled port and simply remains there for the rest of the month (for maintenance). This means that $S_i$ will not visit the remaining ports on its schedule (if any) that month, but this is okay. So the truncation of $S_i$’s schedule will simply consist of its original schedule up to a certain specified day on which it is in a port $P$; the remainder of the truncated schedule simply has it remain in port $P$.
Now the company’s question to you is the following: Given the schedule for each ship, find a truncation of each so that condition $(*)$ continues to hold: no two ships are ever in the same port on the same day. Show that such a set of truncations can always be found, and give an algorithm to find them.
As far as I understand from the example the ship must visit at least one port before it's on maintenance (although this condition is not mentioned in the book). I also assume that each ship is supposed to visit all ports. Then because there're more days than ports and ships we could simply create an array with the all the ports and then upon each encounter of a port we'd check if it's already been visited by another ship: if not then we leave the ship for maintenance at the port; if it's already been visited then we keep going forward until we encounter a previously unvisited port.
This is solution is too simple and it's not using Gale Shapley matching algorithm which I think is expected to be used in the book.