AlgoMaster Logo
AlgoMasterFind MinHash LSH Candidateshard

Find MinHash LSH Candidates

hard

Locality-sensitive hashing avoids comparing every pair of MinHash signatures. It divides signatures into bands and treats an exact match in any band as a candidate similarity.

Design MinHashLshCandidateFinder.candidatePairs(int[][] signatures, int bands). Every row is one document signature. Divide its columns into bands equal, consecutive slices. Documents i and j are candidates when at least one corresponding slice is identical. Return unique pairs [i,j], with i < j, sorted by i and then j.

Example 1:
Example 2:

Constraints

  • 0 <= signatures.length <= 10^4
  • All signatures have the same positive length, divisible by bands.
  • The total number of returned candidate pairs is at most 2 * 10^5.
Hints

Loading...
CallReturns
new MinHashLshCandidateFinder()null
candidatePairs([[1,2,8,9],[1,2,7,7],[3,4,8,9]], 2)[[0,1],[0,2]]

Documents 0 and 1 match in band 0; documents 0 and 2 match in band 1.

Run checks these cases. Submit also runs a larger hidden set.