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 account

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 May 2026

Contest runs May 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.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In