Ibanez Guy
BAN USERWhat if I reverse the input lists to the function?
i.e. instead of func(L1,L2), I pass func(L2,L1)
My take in java. You can get the individual numbers and create char array or whatever.
int value = 152345;
int factor = 1;
while (value >= factor) {
int remainder = value % (factor * 10);
System.out.println(remainder/factor);
value -= remainder;
factor *= 10;
}
I meant element's weight.
for each element(i){
add element (i), weight(i)-1 times.
}
Throwing a quickie out....
Assumption:- List contains unique numbers.
We can traverse the list and add every element (weight-1) times in the list.
We can also keep a track of sum of all unique numbers (not really needed).
Once the list is done, we can pick up any random number and the probability will be same as required in the question.
Is the question about code implementation of synchronization in java or know-hows of internal implementation.
- Ibanez Guy April 21, 2008