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.

40,003 questions

51,950 answers

573 users

How to print the characters need to be removed so that two strings become anagram in VB.NET

1 Answer

0 votes
Imports System
 
Public Class Program
	Public Shared Function PrintCharactersNeedToBeRemovedForAnagram(ByVal str1 As String, ByVal str2 As String) As Integer
        Dim TotalABCLetters As Integer = 26
        Dim count1 As Integer() = New Integer(TotalABCLetters - 1) {}
        Dim count2 As Integer() = New Integer(TotalABCLetters - 1) {}
        Dim size1 As Integer = str1.Length
        Dim size2 As Integer = str2.Length
 
        For i As Integer = 0 To size1 - 1
            count1(Convert.ToInt32(str1(i)) - 97) += 1 ' "a"c = 97 ASCII
        Next
 
        For i As Integer = 0 To size2 - 1
            count2(Convert.ToInt32(str2(i)) - Convert.ToByte("a"c)) += 1
       Next
 
        Dim result As Integer = 0
 
        For i As Integer = 0 To TotalABCLetters - 1
			If Math.Abs(count1(i) - count2(i)) <> 0 Then
                Console.Write(Char.ConvertFromUtf32((i + 97)) & " ")
            End If
        Next
 
        Return result
    End Function
 
    Public Shared Sub Main(ByVal args As String())
        Dim str1 As String = "masterfx"
        Dim str2 As String = "ksampret"
 
        PrintCharactersNeedToBeRemovedForAnagram(str1, str2)
    End Sub
End Class
 
 
 
 
' run:
'
' f k p x
'

 



answered Sep 29, 2022 by avibootz
...