87. longest substring with unique characters

JavaScriptAlgorithm
Is this helpful ?

medium  - accepted / - tried

Given a string, please find the longest substring that has no repeated characters.

If there are multiple result, any one substring is fine.

longestUniqueSubstr('aaaaa')
// 'a'
longestUniqueSubstr('abcabc')
// 'abc', or 'bca', or 'cab'
longestUniqueSubstr('a12#2')
// 'a12#'

Follow-up

What is the time & space cost of your solution ? Could you do it better?

Let's try to solve this problem within 15 mintues.

Discuss(26)