Walmart interview question

Random Song problem. Check Geeksforgeeks