QuickSell interview question

1 DSA question in javascript