Interview question of the issue #258 of rendezvous with cassidoo.
Given two arrays A and B, return the indices at which the two arrays intersect. If the two arrays have no intersection at all, return null. Extra credit: how would you change your code if they were linked lists instead of arrays, if the input were the two head nodes, and you returned the intersection node? (see this diagram if it helps you visualize it)
Example:
let listA = [1,4,5,6]
let listB = [2,3,4,5,6]
> findIntersection(listA, listB)
> [1, 2]
Just pnpm i
to install all dependencies and then pnpm t
to run the tests!