Longest substrings without repeating characters: Difference between revisions

J
(Ada version)
(J)
Line 641:
Length = 0
</pre>
 
=={{header|J}}==
Implementation:<lang J>longnorep=: {{
c=. #y
while. ss=. c ]\ y do.
cnt=. #@~."1 ss
if. c e. cnt do.
~.ss#~ c=cnt return.
end.
c=. c-1
end.
}}</lang>
 
Examples:
 
<lang J> longnorep 'xyzyabcybdfd'
zyabc
cybdf
longnorep 'xyzyab'
zyab
longnorep 'zzzzz'
z
longnorep ''
 
longnorep 'astring'
astring
longnorep 'thisisastringtest'
astring
ringtes
longnorep 'Thequickbrownfoxjumpsoverthelazydog'
Thequickbrownf</lang>
 
=={{header|jq}}==
6,951

edits