Your question is Random Number From Array. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Upstox may need to sample values from an in-memory market-data array for simulations or testing. Implement a function that performs repeated independent random picks, where every array position has the same probability of being selected.
Duplicate values represent separate positions. For example, in [5, 5, 9], the value 5 must have probability 2/3, while 9 has probability 1/3.
Implement random_picks(nums, calls, seed). The function receives a non-empty integer array nums, the number of picks to perform, and an optional integer seed used to make tests reproducible. Return an array containing calls selected values. Each pick must be independent, and the input array must not be modified.
Use Python's random.Random(seed) instance rather than the module-level generator so that the function is deterministic for a supplied seed and does not alter global random state.
def random_picks(nums, calls, seed):