Implement string pattern matching | DoorDash Interview Question