Interesting interview questions

April 12, 2026

Prob.

Sampling from random

Q: use a uniform random generator rand(7) to produce uniform random rand(10).

Combine 2 rand(7) (XX and YY) as Z=7×X+YZ = 7 \times X + Y, we can obtain a uniform sampling [1,49][1, 49]. Then reject if Z>40Z > 40, and finally Z=Zmod10Z' = Z \mod 10.

Coding

Coding is the basic skills for a software engineer, no matter how LLM/agent powerful is.

All permutations

permutation.cc
Loading…

Q: if we have a next_permutation function, how to obtain all possible values of combination Cnk\mathrm{C}_n^k based on this?

Compare a 0-1 array with kk ones and nkn - k zeros. Run next_permutation on this array, each result means a snapshot of combination.