Find Clusters of Instagram Accounts Sharing a Profile Photo Hash

Last updated: November 29, 2026

Quick Overview

Spam rings on Instagram reuse the same profile photo. Using a table of accounts with a perceptual image hash, list every account whose hash is shared by at least five accounts created within the same week, along with the cluster size.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Spam rings on Instagram reuse the same profile photo. Using a table of accounts with a perceptual image hash, list every account whose hash is shared by at least five accounts created within the same week, along with the cluster size.

Fake account detection at Meta often starts with simple duplicate-attribute clustering. The interviewer checks grouping on the shared attribute, joining the cluster stats back to accounts (or using a window COUNT), and filtering out default avatars.

What the Interviewer Expects
  • Groups by photo hash and creation week
  • Uses a window COUNT or a join back to return each member account
  • Excludes the default avatar and NULL hashes
  • Explains why exact hashes miss near-duplicate images
  • Orders clusters by size for review
Key Topics to Cover
window COUNT
GROUP BY
join back
duplicate detection
integrity
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you handle near-duplicate photos with a Hamming distance threshold?
  • How would you combine this signal with shared device or IP?
  • How would you avoid flagging a celebrity fan page trend where many people use the same photo?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

ig_accounts(account_id, created_at, photo_hash, country). A NULL hash means no photo; a known hash value represents the default avatar and must be ignored. Clusters are defined by same hash and same...

Approach

A window COUNT over (hash, week) attaches cluster size to every account in one pass, which is simpler than grouping and joining back. Filter to size at least five....


Submit Your Answer
Markdown supported