Common Values

mediumnumpy_indexing

Implement intersect(a, b).

Given two 1D arrays a and b, return the sorted array of unique values that appear in both. No for/while loops.

Constraints
  • no scipy, sklearn
  • no for/while loops

Your solution

Edit intersect and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

np.intersect1d(a, b) returns the sorted, unique values common to both.