eBay interview question

Question on graphs and strings