I have 2 arrays with objects in them such as:
[{"Start": 1, "End": 2}, {"Start": 4, "End": 9}, {"Start": 12, "End": 16}, ... ]
I want to merge the 2 arrays while removing duplicates. Currently, I am doing the following:
array1.concat(array2);
Then I am doing a nested $.each loop, but as my arrays get larger and larger, this takes O(n^2) time to execute and is not scalable.
I presume there is a quicker way to do this, however, all of the examples I have found are working with strings or integers.
Any recommended algorithms or methods out there to make this faster?
$.eachas the array gets larger.{}then you could check the keys, which is just o(n).