PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Hudson River Trading

Design Insert/Delete/GetRandom with Weighted Sampling

Last updated: Jul 2, 2026

Quick Overview

This Hudson River Trading software engineering question combines insert, delete, random access, and weighted sampling in one data structure design. It is useful preparation for interviews that probe invariants, expected complexity, and how to maintain auxiliary state correctly.

  • medium
  • Hudson River Trading
  • Software Engineering Fundamentals
  • Software Engineer

Design Insert/Delete/GetRandom with Weighted Sampling

Company: Hudson River Trading

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

Design a data structure that supports inserting values, deleting values, and returning a random value. Then extend it so each inserted value has a weight and `getRandom` returns values with probability proportional to weight. ### Constraints & Assumptions - Values are unique unless clarified. - Unweighted operations should be O(1) average time. - Weighted sampling can be O(log n) unless the interviewer requires O(1). - Weights are positive numbers. ### Clarifying Questions to Ask - Can duplicate values be inserted? - Do weights change after insertion? - Are random calls much more frequent than updates? - Is exact weighted probability required? - What language and random library are available? ### What a Strong Answer Covers ```premium-lock What a Strong Answer Covers ``` ### Follow-up Questions - How would you support duplicate values? - How would you update a weight? - How would you test random distribution? - When would alias tables be better than Fenwick trees?

Quick Answer: This Hudson River Trading software engineering question combines insert, delete, random access, and weighted sampling in one data structure design. It is useful preparation for interviews that probe invariants, expected complexity, and how to maintain auxiliary state correctly.

Related Interview Questions

  • Explain Large Memory Allocation, Swap, and C++ Inline Trade-offs - Hudson River Trading (hard)
  • Design an Indexable Deque with O(1) Access - Hudson River Trading (hard)
  • Find a Local Minimum in One and Two Dimensions - Hudson River Trading (hard)
  • Wrap a Fixed-Chunk Stream Reader with Arbitrary-Length Reads - Hudson River Trading (hard)
  • Minimize Array Amplitude After Removing a Contiguous Block - Hudson River Trading (medium)
|Home/Software Engineering Fundamentals/Hudson River Trading

Design Insert/Delete/GetRandom with Weighted Sampling

Hudson River Trading logo
Hudson River Trading
Jul 2, 2026, 7:02 PM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
1
0

Design a data structure that supports inserting values, deleting values, and returning a random value. Then extend it so each inserted value has a weight and getRandom returns values with probability proportional to weight.

Constraints & Assumptions

  • Values are unique unless clarified.
  • Unweighted operations should be O(1) average time.
  • Weighted sampling can be O(log n) unless the interviewer requires O(1).
  • Weights are positive numbers.

Clarifying Questions to Ask

  • Can duplicate values be inserted?
  • Do weights change after insertion?
  • Are random calls much more frequent than updates?
  • Is exact weighted probability required?
  • What language and random library are available?

What a Strong Answer Covers Premium

Follow-up Questions

  • How would you support duplicate values?
  • How would you update a weight?
  • How would you test random distribution?
  • When would alias tables be better than Fenwick trees?
Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Hudson River Trading•More Software Engineer•Hudson River Trading Software Engineer•Hudson River Trading Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,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
  • AI Coding 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.