klepto2 #1 1 fault I think is to have the Initmap() function within the loop, because you reset your map each loop and fill the array with 0.