Striving to become a master Go/Cloud developer; Father ๐จโ๐งโ๐ฆ; ๐ค/((Full Stack Web|Unity3D) + Developer)/g; Science supporter ๐ฉโ๐ฌ; https://coder.today
By visiting all the keys for each element in the source you are making an algorithm of O(nm). Also if the arrays are long enough it will miss the CPU cache for each source item. Its an efficient way basically.
An alternative is to consume more memory and keep the unique elements in a map and going trough the source only once. This way the checks are O(1).
If the elements are objects the memory overhead will be small as you store references.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
By visiting all the keys for each element in the source you are making an algorithm of O(nm). Also if the arrays are long enough it will miss the CPU cache for each source item. Its an efficient way basically.
An alternative is to consume more memory and keep the unique elements in a map and going trough the source only once. This way the checks are O(1).
If the elements are objects the memory overhead will be small as you store references.