Str with Longest Len
Learn this problemProblem statement
A prefix of a string S is any leading contiguous part of S. For example, the string "codility" has the following prefixes: "", "c", "co", "cod", "codi", "codil", "codili", "codilit", and "codility". A prefix of S is called proper if it is shorter 📏 than S.
A suffix of a string S is any trailing contiguous part of S. For example, the string "codility" has the following sufixes: "", "y", "ty", "ity", "lity", "ility", "dility", "odility" and "codility". A suffix of S is called proper if it is shorter than S.
Let's now write a func called strWithLongestLen(String S) in the editor 👉
Task of your func:
: 𓏲🐋 ๋࣭ ࣪endless thanks, spike!˖✩࿐࿔ 🌊
🐳 Source note (Jul 17, 2026): The source asks for the length as an integer, but the online signature and example outputs used strings. They now return integers. The judged core task matches the visible source at about 99%.
Function
strWithLongestLen(S: String) → intExamples
Example 1
S = "abbabba"return = 4abba is both a proper prefix and a proper suffix of S. Its length is 4, and there is no longer valid string.Example 2
S = "codility"return = 0Constraints
1 <= S.length() <= 1,000,000String S consists only lower case english letters (a - z)More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026