PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates fluency with graph traversal, set operations, deduplication, and frequency-based ranking in Python, targeting manipulation of directed "follows" relationships represented as dictionaries and is categorized under Data Manipulation (SQL/Python).

  • Medium
  • Meta
  • Data Manipulation (SQL/Python)
  • Data Engineer

Recommend two-hop follows in Python

Company: Meta

Role: Data Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Onsite

Given a directed "follows" graph as a Python dict[str, list[str]], implement recommend_two_hop(graph, user) that returns the set (or a sorted list) of accounts followed by the user’s followees that the user does not already follow, excluding the user themself. Deduplicate recommendations; if you return a list, sort by descending frequency among two-hop neighbors, then lexicographically. Example: graph = {"A": ["B","C"], "B": ["C","D"], "C": ["E"]} ⇒ recommend_two_hop(graph, "A") = {"D","E"}.

Quick Answer: This question evaluates fluency with graph traversal, set operations, deduplication, and frequency-based ranking in Python, targeting manipulation of directed "follows" relationships represented as dictionaries and is categorized under Data Manipulation (SQL/Python).

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Compute ad impression conversion rates - Meta (medium)
  • Count unconnected posts and reactions - Meta (medium)
  • Count heavy callers in 7 days - Meta (medium)
  • Write SQL for call metrics - Meta (medium)
  • Write SQL for multi-account metrics - Meta (medium)