Write a method that merges two lists of integers, removes duplicates, and returns the result sorted in ascending order.
Input: list1 = [3, 1, 5], list2 = [2, 1, 4]
Output: [1, 2, 3, 4, 5]
Explanation: The two lists are merged, duplicates (1) are removed, and the result is sorted.
Input: list1 = [10, 8], list2 = [6, 8, 12]
Output: [6, 8, 10, 12]
Explanation: The lists are merged, the duplicate 8 is removed, and the final list is sorted.
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 September 2026 (Sep 1–15)Sponsored by FLXBL
Contest runs September 1 - 15. Complete challenges to climb the leaderboard!
1st & 2nd: Salesforce certification exam voucher — see all prizes
Only the 15 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.