eBay interview question

LC problem and some behavior