Imports System
Public Class Program
Public Shared Function CanStringBeRearrangedAsPalindrome(ByVal str As String) As Boolean
Dim ascii_count As Integer() = New Integer(255) {}
For i As Integer = 0 To str.Length - 1
ascii_count(Convert.ToInt32(str(i))) += 1
Next
Dim odd As Integer = 0
For i As Integer = 0 To 256 - 1
If (ascii_count(i) And 1) <> 0 Then
odd += 1
End If
If (odd > 1)
return False
End if
Next
Return True
End Function
Public Shared Sub Main(ByVal args As String())
Const str As String = "abcdacdb"
Dim result As String = If (CanStringBeRearrangedAsPalindrome(str), "Yes", "No")
Console.WriteLine(result)
result = If (CanStringBeRearrangedAsPalindrome("abcca"), "Yes", "No")
Console.WriteLine(result)
result = If (CanStringBeRearrangedAsPalindrome("abcb"), "Yes", "No")
Console.WriteLine(result)
End Sub
End Class
' run:
'
' Yes
' Yes
' No
'