andere longestDistance implementation