Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,915 questions

51,848 answers

573 users

How to find the longest substring without repeating characters in VB.NET

1 Answer

0 votes
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
'

 



answered Jul 18, 2023 by avibootz
edited Jul 18, 2023 by avibootz
...