Browse and solve 1,200+ machine learning coding challenges on Deep-ML. Filter by difficulty (beginner, intermediate, advanced) and category (linear algebra, machine learning, deep learning, NLP, computer vision). Write Python solutions in the browser and get instant feedback against test cases.
Given a string s, return the length of the longest substring that contains no repeating characters.
A substring is a contiguous sequence of characters within the string. If the string is empty, the answer is 0.
Write a function longest_unique_substring(s) that returns an integer: the length of the longest substring of s in which every character is distinct.
s = "abcabcbb"
3
The longest substring with all distinct characters is "abc", which has length 3. After that, characters begin to repeat, so no longer distinct substring exists.