Given two lists, combine them into a Map where the first list provides the keys and the second list provides the values. If the lists have different lengths, only zip up to the shorter length. Return an empty map for null or empty inputs.
Examples:
Input: keys = ['a', 'b', 'c'], vals = [1, 2, 3]
Output: {'a': 1, 'b': 2, 'c': 3}
Explanation: Each key is paired with the value at the same index
Input: keys = ['x', 'y'], vals = [10, 20, 30]
Output: {'x': 10, 'y': 20}
Explanation: Only the shorter list length is used, so index 2 is ignored
Input: keys = [], vals = []
Output: {}
Explanation: Empty lists produce an empty map
Input: keys = null, vals = [1, 2]
Output: {}
Explanation: Null input returns an empty map
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay November 2026 (Nov 16–30)Sponsored by FLXBL
Contest runs November 16 - 30. Complete challenges to climb the leaderboard!
Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes
Only the 15 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.