Tap here to switch tabs
Problem
Submissions

Problem: Longest Happy Prefix

Longest Happy Prefix asks you to find the longest non-empty prefix of a string that also appears as its suffix, without using the entire string. Return an empty string when no such prefix exists.

Statement

Given a string, s, find the longest happy prefix. If no such prefix exists, return an empty string "".

Note: A happy prefix of a string is a non-empty substring at the beginning that also appears at the end (but not the entire string itself).

Constraints:

  • 1<=1 <= s.length <=105<= 10^5

  • s contains only lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Happy Prefix

Longest Happy Prefix asks you to find the longest non-empty prefix of a string that also appears as its suffix, without using the entire string. Return an empty string when no such prefix exists.

Statement

Given a string, s, find the longest happy prefix. If no such prefix exists, return an empty string "".

Note: A happy prefix of a string is a non-empty substring at the beginning that also appears at the end (but not the entire string itself).

Constraints:

  • 1<=1 <= s.length <=105<= 10^5

  • s contains only lowercase English letters.