'keep track of pairs changement
Suppose I have a certain number of consecutive numbers to which I assign another number. For example, the following pairs:
0 -> 1
1 -> 2
2 -> 0
3 -> 0
4 -> 1
5 -> 3
Next, I call a function that adjusts the numbers on the right:
0 -> 2
1 -> 0
2 -> 0
3 -> 0
4 -> 2
5 -> 2
Now I need to loop over all the possible numbers that are on the right side (0 and 2 in this case) and do something with them. The problem is that after calling the function, I don't know how many different numbers are on the right side, so now I can't determine the number of iterations of my loop and I also don't know which numbers to loop over. So I don't know which is the most-performant way to keep track of the changes made by the function. Can anyone help me?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
