Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.
/**
* @param {number[]} nums
* @return {number[]}
*/
// Approach 1: Using a map/object/hashtable to keep track of numbers we've seen before
// Loop through the nums array and add numbers that exist into the map/object
// Loop from 1..nums.length and if a number doesn't exist in the map, add it to result array
// O(N) time, O(N) space
// Approach 2: Using a set
// Loop through numbers [1..n] and add them to set
// Loop through nums and if number is not in set, add it to result array
// O(N) time, O(N) space
varfindDisappearedNumbers=function(nums){
// Initialize a map to keep track of numbers that exist in nums
const numsMap =newMap();
// Loop through the nums array and add numbers that exist into the map
nums.forEach((num)=>{ numsMap.set(num,true)});
const result =[];
// Loop from 1..nums.length and if a number doesn't exist in the map, add it to result array