Linear time distanced implemented (character level and word level)