Tencent Question

input
A list of machine numbers, and corresponding weights

output
Output the numbers of two machines each time, and they cannot be the same

example
input {[1,2,3,4], [20,35,25,20]}
output
(1,3)
(2,4)
.....

When we run enough times, the ratio of the number of times each machine's number appears is 20:35:25:20

follow up
Output the numbers of k machines each time, and they cannot be the same(k > 2)

Similar to the problem leetcode 528,but i don't know how to solve it

Comments (1)