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!

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

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