// Intersection Of Sorted ArraysBookmark Suggest Edit

// Find the intersection of two sorted arrays.
// OR in other words,
// Given 2 sorted arrays, find all the elements which occur in both the arrays.

// Example :

// Input :
//     A : [1 2 3 3 4 5 6]
//     B : [3 3 5]

// Output : [3 3 5]

// Input :
//     A : [1 2 3 3 4 5 6]
//     B : [3 5]

// Output : [3 5]

/**
 * @param {arr[]} A
 * @param {arr[]} B
 * @return {arr[]}
 */

function intersect(A, B) {
  const map = {};
  for (let i = 0; i < A.length; i += 1) {
    if (map[A[i]]) {
      map[A[i]] += 1;
    } else {
      map[A[i]] = 1;
    }
  }
  const result = [];
  for (let j = 0; j < B.length; j += 1) {
    if (map[B[j]]) {
      result.push(B[j]);
      map[B[j]] < 1 ? delete map[B[j]] : map[B[j]] -= 1;
    }
  }
  return result;
}
console.log(intersect([1], [1]));

@@ -434,16 +434,605 @@
 %5D%7D%0A */%0A%0A
+// create a map to store each value from the first array and check against the second array%0A// loop through first array%0A  // if the element hasnt existed%0A    // create it in map and set it to 1%0A  // if element exists%0A    // increment count%0A// create result variable to return our intersecting integers%0A// loop through second array%0A  // if current element exists on our map%0A    // it is an intersecting integer%0A    // push the intersecting integer into result array%0A    // if the count was 1 we delete the key%0A    // if count is larger than one, decrement by 1%0A// return result at the end%0A%0A
 function

add logic