 When such a string is found, the index for the string without the last character (i.e., the longest substring that "is" in the dictionary) is retrieved from the dictionary and sent to output, and the new string (including the last character) is added to the dictionary with the next available code.The last input character is then used as the next starting point to scan for substrings.In this way, successively longer strings are registered in the dictionary and available for subsequent encoding as single output values.