Given three lists of integers, return the sorted list of distinct values that appear in all three lists. If any input list is null or no values are common, return an empty list. Each value in the result should appear exactly once.

Examples:

Input: a = [1, 2, 3], b = [2, 3, 4], c = [3, 4, 5] Output: [3] Explanation: Only 3 appears in all three lists Input: a = [1, 2, 3, 4], b = [2, 3, 4, 5], c = [3, 4, 5, 6] Output: [3, 4] Explanation: 3 and 4 appear in all three lists, sorted ascending Input: a = [1, 2], b = [3, 4], c = [5, 6] Output: [] Explanation: No common values across the lists Input: a = [], b = [1], c = [1] Output: [] Explanation: An empty list has no common values Input: a = null, b = [1], c = [1] Output: [] Explanation: A null list yields an empty result
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 November 2026 (Nov 1–15)Sponsored by FLXBL

Contest runs November 1 - 15. Complete challenges to climb the leaderboard!

Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes

Only the 15 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