Given an array of integers and an integer ID, return the array with the ID either added if it's not present or removed if it's already present.
Explanation: Step 1: Check if ID 4 is present in the array. Since it's not present, we proceed to Step 2. Step 2: Add ID 4 to the array. The updated array is [1, 2, 3, 4, 5, 6].
Explanation: Step 1: Check if ID 4 is present in the array. Since it's present, we proceed to Step 2. Step 2: Remove ID 4 from the array. The updated array is [1, 2, 3, 5, 6].
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak