Measures overlap between two **sets**. Used in NLP for document similarity, deduplication, and MinHash LSH.
J(A, B) = |A ∩ B| / |A ∪ B|jaccard([1,2,3], [2,3,4]) → 0.5
# Intersection: {2,3} → 2
# Union: {1,2,3,4} → 4
# 2/4 = 0.5Round to **5 decimal places**.
Similar Problems
Test Cases (3 visible · 1 hidden)
Case 1: Partial overlap
Input: jaccard_similarity([1,2,3],[2,3,4])
Expected: 0.5
Case 2: Identical
Input: jaccard_similarity([1,2],[1,2])
Expected: 1.0
Case 3: No overlap
Input: jaccard_similarity([1,2],[3,4])
Expected: 0.0
⌘↵ Run · ⌘⇧↵ Submit