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!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow 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 Mar/April 2026
Contest runs March 3 - April 30. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.