Walmart interview question

Please do some algorithms