You are provided with a list of contacts named allContacts
and a list of strings named zipCodes
.
Each contact in allContacts has at least two fields: Id
and MailingPostalCode
.
Your task is to return a Set of Contact Ids whose Contact's MailingPostalCode
matches any zip code in the zipCodes
list.
zipCodes
and allContacts
may be empty or null.
Example 1:
Input:
allContacts =[ {"Id": "0038b00003H78BjAAJ", "MailingPostalCode": "75024"}, {"Id": "0038b000034AzkgAAC", "MailingPostalCode": "66045"}, {"Id": "0038b00003H787MAAR", "MailingPostalCode": "90403"} {"Id": "0038b00003H785VAAR", "MailingPostalCode": "90403"} ]
zipCodes = ['90403']
Output:[ '0038b00003H787MAAR', '0038b00003H785VAAR']
Explanation: The last two contacts have a MailingPostalCode that is in the zipCodes list. Their Ids are returned.
Example 2:
Input:
allContacts =[ {"Id": "0038b00003H78BjAAJ", "MailingPostalCode": "75024"}, {"Id": "0038b000034AzkgAAC", "MailingPostalCode": "66045"}, {"Id": "0038b00003H787MAAR", "MailingPostalCode": "90403"} {"Id": "0038b00003H785VAAR", "MailingPostalCode": "90403"} ]
zipCodes = ['90403', '75024']
Output: ['0038b00003H78BjAAJ', '0038b00003H787MAAR', '0038b00003H785VAAR']
Explanation: The first contact and the last two contacts have a MailingPostalCode that is in the zipCodes list. Their Ids are returned.
Example 3:
Input:
allContacts =[ {"Id": "0038b00003H78BjAAJ", "MailingPostalCode": "75024"}, {"Id": "0038b000034AzkgAAC", "MailingPostalCode": "66045"}, {"Id": "0038b00003H787MAAR", "MailingPostalCode": "90403"} {"Id": "0038b00003H785VAAR", "MailingPostalCode": "90403"} ]
zipCodes = ['54045']
Output:[]
Explanation: None of the Contacts had a matching MailingPostalCode, so an empty list was returned.