Imports System
Imports System.Collections.Generic
Public Class Program
Public Shared Sub printPermutationRows(ByVal matrix As Integer(,), ByVal givenrow As Integer)
Dim rows As Integer = matrix.GetLength(0)
Dim cols As Integer = matrix.GetLength(1)
Dim St As HashSet(Of Integer) = New HashSet(Of Integer)()
For j As Integer = 0 To cols - 1
st.Add(matrix(givenrow, j))
Next
For i As Integer = 0 To rows - 1
If i = givenrow Then
Continue For
End If
Dim j As Integer = 0
While j < cols
If Not st.Contains(matrix(i, j)) Then
Exit While
End If
j += 1
End While
If j <> cols Then
Continue For
End If
Console.Write(i & ", ")
Next
End Sub
Public Shared Sub Main(ByVal args As String())
Dim givenrow As Integer = 1
Dim matrix = New Integer(,) {
{7, 9, 4, 3, 1},
{4, 7, 9, 1, 3},
{4, 7, 8, 1, 2},
{1, 6, 9, 7, 4},
{9, 1, 3, 7, 4}}
printPermutationRows(matrix, givenrow)
End Sub
End Class
' run:
'
' 0, 4,
'