Given two Lists of Integers, return a List containing elements that appear in exactly one of the two lists (symmetric difference). The result should be sorted in ascending order.
Examples:
Input: list1 = [1, 2, 3, 4], list2 = [3, 4, 5, 6]
Output: [1, 2, 5, 6]
Explanation: Elements 1 and 2 appear only in list1, elements 5 and 6 appear only in list2
Input: list1 = [10, 20, 30], list2 = [40, 50, 60]
Output: [10, 20, 30, 40, 50, 60]
Explanation: No common elements, so all elements from both lists are included
Input: list1 = [5, 10, 15], list2 = [5, 10, 15]
Output: []
Explanation: All elements are common to both lists, so no unique elements exist
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.