Imports System
Public Class Program
Private Shared Sub findLongestSubstringWithoutRepeatingCharacters(ByVal str As String)
Dim str_size As Integer = str.Length
Dim start As Integer = 0, [end] As Integer = 0
Dim start_sub As Integer = 0, end_sub As Integer = 0
Dim ASCII As Integer() = New Integer(255) {}
While [end] < str_size
If ASCII(Convert.ToByte(str([end]))) > 0 Then
While str(start) <> str([end])
ASCII(Convert.ToByte(str(start))) = 0
start += 1
End While
start += 1
Else
ASCII(Convert.ToByte(str([end]))) = [end] + 1
If [end] - start > end_sub - start_sub Then
start_sub = start
end_sub = [end]
End If
End If
[end] += 1
End While
For i As Integer = start_sub To end_sub
Console.Write(str(i))
Next
End Sub
Public Shared Sub Main(ByVal args As String())
Dim str As String = "xwwwqfwwxqwyq"
findLongestSubstringWithoutRepeatingCharacters(str)
End Sub
End Class
' run:
'
' xqwy
'