Anti-Join

MediumData EngineeringArraySortingSQL

Description

Given a left table and a right table as arrays of [key, value] pairs, return the left rows whose key does not appear in the right table, preserving left order.

Examples

Input:[[1,10],[2,20],[3,30]], [[2,0],[3,0]]
Output:[[1,10]]
Explanation:

Only left rows whose key is absent from the right table survive, keeping their original order.

Input:[[1,1],[2,2]], [[1,9]]
Output:[[2,2]]
Explanation:

Only left rows whose key is absent from the right table survive, keeping their original order.

Input:[[1,1]], []
Output:[[1,1]]
Explanation:

Only left rows whose key is absent from the right table survive, keeping their original order.

Constraints

  • 0 ≤ each table ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.