Longest substrings without repeating characters: Difference between revisions
Longest substrings without repeating characters (view source)
Revision as of 02:13, 12 July 2022
, 1 year agoJ
(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}}==
|