elle-johnnie / array_intersection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array Intersection

Determines intersection of two sets of input integer arrays.

Exercise

  • Design and implement a method that takes two integer arrays and returns their intersection. The two input arrays have non repeating elements.
  • For example,
    • intersection of [2, 3, 4] and [4, 5, 6] is [4]
    • intersection of [50, 43, 25, 72] and [25, 36, 43, 50, 80] is [50, 25, 43]
    • intersection of [9, 30, 42] and [56, 34, 90, 32] is []
  • Share and explain the time and space complexities for your solution.
  • If you think of multiple approaches to solve the problem, implement the solution which minimizes space complexity. Explain the other approaches, and your decision in comments above the code.

Note: Do not use Ruby provided functionality.

About


Languages

Language:Ruby 100.0%