You’re on the fraud-prevention team at a large fintech app processing tens of millions of login events per day. Each event includes a session token string. Repeated characters in a short window are a strong signal of bot-generated tokens, and you need a fast way to measure “uniqueness density” in real time.
Given a string s, return the length of the longest substring (contiguous segment) that contains no repeating characters.
s: strint — the maximum length of a substring with all distinct charactersA substring is defined by two indices l and r (0 <= l <= r < len(s)) and includes s[l:r+1]. You must find the maximum possible length among all substrings where every character appears at most once.
s = "abcabcbb"3"abc", "bca", and "cab", each of length 3. Any longer window repeats a character.s = "pwwkew"3"wke" (length 3). Note that "pwke" is not valid because it is not contiguous.0 <= len(s) <= 10^5s consists of standard ASCII characters (you may assume up to 128 distinct characters)s is empty, return 0.'A' and 'a' are different).