------
## 最终结论
```python
def last_substring(s: str) -> str:
    max_substring = ""
    n = len(s)
    
    # Start from the end of the string and compare characters
    for i in range(n - 1, -1, -1):
        if s[i:] > max_substring:
            max_substring = s[i:]
    
    return max_substring

# Example usage:
print(last_substring("abab"))  # Output: "bab"
print(last_substring("leetcode"))  # Output: "tcode"
```