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!

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

Note

You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.