We’re preparing your current view and syncing the latest data.
Given a string s, return the longest prefix of s which is also a suffix (excluding the whole string itself) called the longest happy prefix. A happy prefix is defined as a non-empty prefix that is also a suffix of the string but not the entire string itself.
A single string s is given as input.
Return a string representing the longest happy prefix of the input string s. If no such prefix exists, return an empty string.
1 <= s.length <= 10^5 s consists of lowercase English letters only.