PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Meta

Design weighted random index picker

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithm design and data structure selection for weighted random sampling, along with probability reasoning, correctness proof, time and space complexity analysis, and numerical stability considerations.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Design weighted random index picker

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

Design and implement a data structure that, given an array of positive integer weights w[0..n−1], supports pick() that returns index i with probability proportional to w[i]. Optimize for many pick() calls after a one-time initialization. Specify the API, prove correctness, and analyze time and space. Follow-ups: support point updates to weights; handle large totals without precision loss; compare prefix-sum binary search with the alias method; design tests to detect sampling bias.

Quick Answer: This question evaluates algorithm design and data structure selection for weighted random sampling, along with probability reasoning, correctness proof, time and space complexity analysis, and numerical stability considerations.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Maze and Suffix Problems - Meta (medium)
Meta logo
Meta
Jul 29, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
3
0

Design and implement a data structure that, given an array of positive integer weights w[0..n−1], supports pick() that returns index i with probability proportional to w[i]. Optimize for many pick() calls after a one-time initialization. Specify the API, prove correctness, and analyze time and space. Follow-ups: support point updates to weights; handle large totals without precision loss; compare prefix-sum binary search with the alias method; design tests to detect sampling bias.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
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.