Given a list of n integers where every value is in the range 1 to n (inclusive), some numbers appear more than once and others are missing. Return a list of all integers in the range 1 to n that do NOT appear in the input, in ascending order. Return an empty list for null or empty input.

Examples:

Input: nums = [4,3,2,7,8,2,3,1] Output: [5,6] Explanation: n = 8; 5 and 6 do not appear in the list Input: nums = [1,1] Output: [2] Explanation: n = 2; 2 is missing because 1 appears twice Input: nums = [1,2,3] Output: [] Explanation: All values 1 to 3 are present, nothing is missing
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

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.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In