#31Longest Unique Website Visit Sequence
A browser analytics system records a user's website visits in chronological order. You are given a string visits, where each character represents a website identifier visited by the user. A continuous browsing session is a consecutive sequence of website visits.
Find the length of the longest continuous browsing session in which no website is visited more than once. A website may appear multiple times in the complete browsing history, but within the selected continuous session, every website must be unique.
Real-World Applications: User Session Diversity Analysis; Network Traffic Pattern Analysis; Content Recommendation Analysis;
Examples
Example 1
Input: visits = "abcad"
Output: 4
Explanation:
The longest unique browsing sequence is "bcad", containing four different websites.
Example 2
Input: visits = "aaab"
Output: 2
Explanation:
The longest unique sequence is "ab".
Example 3
Input: visits = "xyzzabc"
Output: 4
Explanation:
The longest unique sequence is "zabc", which contains four different website identifiers.
Constraints
- 0 <= visits.length <= 100000
- visits consists of uppercase English letters, lowercase English letters, digits, spaces, and common symbols.
- Each character represents a website identifier.
- The input may contain repeated website identifiers.
- The answer fits within a 32-bit signed integer.