eBay interview question

Dsa question was based on python