Identify Pirate Themes Using Similarity Score Algorithm
Company: Shopify
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates understanding of similarity scoring, set-based comparison of structured records, and practical data deduplication techniques commonly used in data science.
Constraints
- 0 <= len(pirate_themes) <= 1000
- 0 <= len(custom_themes) <= 1000
- Sum of unique keys across all themes <= 1e5
- Each key is a non-empty string (case-sensitive)
- 0.0 <= threshold <= 1.0
- Return indices in ascending order
- If pirate_themes is empty, return []
Hints
- Convert dictionary keys to sets and use set intersection/union sizes.
- Precompute sets for pirate themes to reuse across comparisons.
- Jaccard similarity is |A ∩ B| / |A ∪ B|; treat both-empty as 1.0 to avoid division by zero.
- For each custom theme, compare against all pirate themes and take the maximum similarity.