87. longest substring with unique characters

JavaScriptAlgorithm

easy  - 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?

What is time & space complexity of your approach?

(61)