87. longest substring with unique characters

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?

Always try to find a better approach.

(92)