47 lines
697 B
C#
47 lines
697 B
C#
var sol = new Solution();
|
|
|
|
var cases = new (int[][] mat, int k, bool expected)[]
|
|
{
|
|
(
|
|
new[]
|
|
{
|
|
new[] { 1, 2, 3 },
|
|
new[] { 4, 5, 6 },
|
|
new[] { 7, 8, 9 }
|
|
},
|
|
4,
|
|
false
|
|
),
|
|
(
|
|
new[]
|
|
{
|
|
new[] { 1, 2, 1, 2 },
|
|
new[] { 5, 5, 5, 5 },
|
|
new[] { 6, 3, 6, 3 }
|
|
},
|
|
2,
|
|
true
|
|
),
|
|
(
|
|
new[]
|
|
{
|
|
new[] { 2, 2 },
|
|
new[] { 2, 2 }
|
|
},
|
|
3,
|
|
true
|
|
)
|
|
};
|
|
|
|
foreach (var (mat, k, expected) in cases)
|
|
{
|
|
var actual = sol.AreSimilar(mat, k);
|
|
Console.WriteLine($"mat = {FormatMatrix(mat)}, k = {k} -> {actual} (expected: {expected})");
|
|
}
|
|
|
|
static string FormatMatrix(int[][] mat)
|
|
{
|
|
var rows = mat.Select(row => $"[{string.Join(",", row)}]");
|
|
return $"[{string.Join(",", rows)}]";
|
|
}
|