------
## 最终结论
```python
def longest_happy_prefix(s: str) -> str:
    n = len(s)
    lps = [0] * n  # Longest Prefix Suffix array
    length = 0  # Length of the previous longest prefix suffix
    i = 1

    # Preprocess the pattern (calculate LPS array)
    while i < n:
        if s[i] == s[length]:
            length += 1
            lps[i] = length
            i += 1
        else:
            if length != 0:
                length = lps[length - 1]
            else:
                lps[i] = 0
                i += 1

    # The longest happy prefix is the last value in the LPS array
    happy_prefix_length = lps[-1]
    
    # Return the longest happy prefix or an empty string if none exists
    return s[:happy_prefix_length] if happy_prefix_length > 0 else ""
```