Use a set instead of an array for the right hand side.
Membership check in a set scales with O(1), whereas an array it scales with O(n).
7 Likes
Use a set instead of an array for the right hand side.
Membership check in a set scales with O(1), whereas an array it scales with O(n).