[algorithms][distance] rename beyond to last