Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-123

Random Search Picks

Problem

Pick k distinct candidate indices for random search. Call random.seed(seed), shuffle range(n_candidates), and return the first k indices sorted ascending.

Return [] if k <= 0.

Hint

Seeded shuffling gives reproducible random subsets without replacement.

Test cases

case 1
in: [10,3,42]
expected: [2,3,7]
case 2
in: [6,2,7]
expected: [0,4]
case 3
in: [4,4,0]
expected: [0,1,2,3]
case 4
in: [5,1,123]
expected: [3]
Starter codePython
import random
def random_search_picks(n_candidates, k, seed):
    # Your code here
    pass

4 test cases · run your code against them in the editor