Create a method that performs various operations on two sets of integers and returns the results in a map. The operations to implement are:

  1. Union - all elements that are in either set
  2. Intersection - only elements that are in both sets
  3. Difference - elements that are in the first set but not in the second
  4. Symmetric Difference - elements that are in either set but not in both

Examples:

Input: set1 = {1, 2, 3}, set2 = {3, 4, 5} Output: { 'union' => {1, 2, 3, 4, 5}, 'intersection' => {3}, 'difference' => {1, 2}, 'symmetricDifference' => {1, 2, 4, 5} } Input: set1 = {10, 20, 30}, set2 = {40, 50, 60} Output: { 'union' => {10, 20, 30, 40, 50, 60}, 'intersection' => {}, 'difference' => {10, 20, 30}, 'symmetricDifference' => {10, 20, 30, 40, 50, 60} }
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.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In