given a list of integers as such: [5,2,3,1] write getRandom() function where:

total = 1+2+3+5 = 11

1 is given with 1 / 11 chance

2 is given with 2 / 11 chance

3 is given with 3 / 11 chance

5 is given with 5 / 11 chance

Can you do this in constant space?