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 July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.