PACT Pharma Interview Question

Easy problem from Leet code