Premium problem93. Rows Containing Each Row of B

Hard Locked

Return the indices of rows of A that draw from every row of B:

  • a row of A qualifies when it contains at least one element from each row of B (not all of them)
  • A has shape (8, 3), B has shape (2, 2)
  • position within the row does not matter

Input

A =
[[0 1 2]
 [3 4 0]
 [1 0 4]
 [2 2 2]
 [4 3 1]
 [0 0 0]
 [1 2 3]
 [4 4 4]]
B =
[[0 1]
 [3 4]]

Output

[1 2 4 6]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)