For example
inputarray = [1, 4, 5, 9];
array1 = [1, 2, 3, 4, 5, 6, 7];
array2 = [8, 9, 10, 11, 12, 13, 14];
I would like to match inputarray with both array1 & array2.In this current scenario 1,4,5 belongs to the array1 and 9 belongs to the second array.I am expecting the output like
outputarray1=[1,4,5]
outputarray2=[9]
Suggest me best way to do this problem.I mean with less complexity.Thanks in advance.
array1andarray2overlap? What if they are the same? What's the current complexity? Do you mean "less complexity" in terms of asymptotic behaviour? Or in terms of performance? How is this related to node.js?kitems it's usually O(n * k), unless you have some precondition.