Randomized LeetCode Problems: All 12, With Python Solutions

Every problem in this library that LeetCode tags Randomized 12 in total, 12 of them with a complete Python solution, a worked example and the time and space complexity of the approach.

  • 12 problems
  • 0 Easy
  • 9 Medium
  • 3 Hard

Randomized problems by difficulty

Problems with a complete Python solution are listed first, then by ascending problem number.

Medium (9)

#ProblemDifficultyTopics
380Insert Delete GetRandom O(1)MediumDesign, Array, Hash Table +2
382Linked List Random NodeMediumReservoir Sampling, Linked List, Math +1
384Shuffle an ArrayMediumDesign, Array, Math +1
398Random Pick IndexMediumReservoir Sampling, Hash Table, Math +1
470Implement Rand10() Using Rand7()MediumMath, Rejection Sampling, Probability and Statistics +1
478Generate Random Point in a CircleMediumGeometry, Math, Rejection Sampling +1
497Random Point in Non-overlapping RectanglesMediumReservoir Sampling, Array, Math +4
519Random Flip MatrixMediumReservoir Sampling, Hash Table, Math +1
528Random Pick with WeightMediumArray, Math, Binary Search +2

Hard (3)

#ProblemDifficultyTopics
381Insert Delete GetRandom O(1) - Duplicates allowedHardDesign, Array, Hash Table +2
710Random Pick with BlacklistHardArray, Hash Table, Math +3
1515Best Position for a Service CentreHardGeometry, Array, Math +1

When the Randomized problem arrives live

Stealth Interview is a desktop app for macOS and Windows. It reads the coding problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer is saying — while staying invisible to screen sharing.