dynamic programming to track the nearest avaiable char
del previous helper function of iterating finding the nearest hits
helper function to update the current row if a char hitted in target