Get Longest Substring
Problem Overview
- Given a lowercase product name string s, find the length of the longest substring longer than 1 where the first character is lexicographically smaller than the last.
- Input: string s (2 ≤ n ≤ 1e5); Output: int length of the longest valid substring, or 0 if none.
- Context: Amazon product search team analyzing product names.
- From Amazon interviews; a common coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
