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

🏆 All Time Leaderboard

Contest runs January 1, 1970 - December 31, 9999. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In