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

// Find all the elements that appear twice in this array.

// Could you do it without extra space and in O(n) runtime?

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

// Output:
// [2,3]

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


var findDuplicates = function(nums) {
    var result = [];
    for (var i = 0; i < nums.length; ++i) {
        var index = Math.abs(nums[i])-1;
        if (nums[index] < 0){
            result.push(Math.abs(index+1));
        }
        nums[index] = -nums[index];
    }
    return result;
};

@@ -353,16 +353,166 @@
 %7D%0A */%0A%0A%0A
+%0A// store and flip each number at position i-1 to negative.%0A// if the number at position i-1 is already negative, i is the number that occurs twice.%0A%0A
 var find
@@ -603,11 +603,11 @@
 th; 
+i
 ++
-i
 ) %7B%0A
@@ -646,16 +646,21 @@
 s%5Bi%5D)-1;
+ // 1
 %0A       
@@ -681,16 +681,54 @@
 x%5D %3C 0)%7B
+ // if number is negative it's occured
 %0A       
@@ -763,16 +763,38 @@
 dex+1));
+ // push regular value
 %0A       
@@ -831,16 +831,42 @@
 %5Bindex%5D;
+ // set number as negative
 %0A    %7D%0A 

add setps and notes