CarWale Interview Question

array based and string reduction que