July 2018
Beginner
202 pages
5h 4m
English
Scenario
We have already seen an algorithm that produces an intersection between two input arrays in Snippet 1.6.
We have already shown how the runtime complexity of this algorithm is O(n2). Can we write an algorithm with a faster runtime complexity?
To find a solution for this problem, think about how you would you go about finding the intersection by hand between two decks of playing cards. Imagine you take a subset from each shuffled deck; which technique would you use to find the common cards between the first and second deck?
Aim
To improve the performance of the array intersection algorithm and reduce its runtime complexity.
Prerequisites
Read now
Unlock full access