Merge two maps of String to Integer. If a key exists in both maps, sum their values. Return the merged map.
Examples:
Input: map1 = {a: 1, b: 2}, map2 = {b: 3, c: 4}
Output: {a: 1, b: 5, c: 4}
Explanation: Key b exists in both, so values are summed (2 + 3 = 5)
Input: map1 = {x: 10}, map2 = {y: 20}
Output: {x: 10, y: 20}
Explanation: No common keys, simple merge
Input: map1 = {}, map2 = {a: 1}
Output: {a: 1}
Explanation: One map is empty, return the non-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.