Given an array of student numbers, find all absent student numbers. The absent student numbers are the numbers in the range [1, max(arr)] that are not present in arr.
Explanation: Step-by-step: Given the input array [1, 2, 3, 4, 5], we first find the maximum number in the array, which is 5. Then, we generate a list of numbers from 1 to the maximum number (6). Finally, we return the list of numbers that are present in the range [1, 6] but not in the input array [1, 2, 3, 4, 5], which is [6].
Explanation: Step-by-step: Given the input array [1, 2, 4, 5], we first find the maximum number in the array, which is 5. Then, we generate a list of numbers from 1 to the maximum number (6). Finally, we return the list of numbers that are present in the range [1, 6] but not in the input array [1, 2, 4, 5], which is [3, 6].
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak