<commit_before>// Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

// Find all the elements of [1, n] inclusive that do not appear in this array.

// Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

// Example:

// Input:
// 1. [4,3,2,7,8,2,3,1]
// 2. [2, 2]
// 3. [1, 1]

// Output:
// 1. [5,6]
// 2. [1]
// 3. [2]

/**
 * @param {number[]} nums
 * @return {number[]}
 */


 // -------------- Naive
// create a result array to return missing numbers
// create a cache to check if a number has came up
// loop through nums
  // cache each number
// create a for loop the size of the array
  // if number hasnt been cached somewhere in bewteen
    // push into result
// return result that has missing numbers

var findDisappearedNumbers = function(nums) {
    var result = [],
        cache = {};
    for( var i=0; i<nums.length; i++ ){
        if(!cache[nums[i]]) cache[nums[i]] = true;
    }
    for( var j=1; j<=nums.length; j++ ){
        if(!cache[j]) result.push(j);
    }
    return result;
};

<commit_msg>edit solution<commit_after>// Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

// Find all the elements of [1, n] inclusive that do not appear in this array.

// Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

// Example:

// Input:
// 1. [4,3,2,7,8,2,3,1]
// 2. [2, 2]
// 3. [1, 1]

// Output:
// 1. [5,6]
// 2. [1]
// 3. [2]

/**
 * @param {number[]} nums
 * @return {number[]}
 */


 // -------------- Naive
// create a result array to return missing numbers
// create a cache to check if a number has came up
// loop through nums
  // cache each number
// create a for loop the size of the array
  // if number hasnt been cached somewhere in bewteen
    // push into result
// return result that has missing numbers

var findDisappearedNumbers = function(nums) {
    var result = [],
        cache = {};
    for( var i=0; i<nums.length; i++ ){
        if(!cache[nums[i]]) cache[nums[i]] = true;
    }
    for( var j=1; j<=nums.length; j++ ){
        if(!cache[j]) result.push(j);
    }
    return result;
};

{'fraction_non_alphanumeric': 0.15910073497622135, 'fraction_numerical': 0.02248162559446606, 'mean_word_length': 2.428148148148148, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5439102', 'n_tokens_mistral': 799, 'n_tokens_neox': 770, 'n_words': 319}