Search code examples
loopstraversal

How to find out how many times each process(or data) traversed using array


Let there are 4 processes (20,30,40,50). I want to decrement 3 from each process when it is traversed first time, decrement 6 if it is traversed second time and remaining value when traversed third time. constraint: *any process can be picked up randomly (ie not in a sequential manner).


Solution

  • Through I'm little late, but you can try a hack. For this what you'll need is either use mapping or a counter for each element of array.