Calculate Jaccard Similarity Score for Two String Lists
ShopifyData Scientist · OnsiteLast updated
This question evaluates understanding of similarity metrics and competency in comparing string collections, reflecting knowledge of set-theoretic concepts and manipulation of collection data structures used in data processing.
Scenario
During pair programming, the interviewer asks you to compare two lists of merchant tags and quantify their similarity.
Question
Implement a Python function that takes two lists of strings and returns their Jaccard similarity score.
Hints
Convert both lists to sets, then compute |A ∩ B| ÷ |A ∪ B|.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.