2946. Matrix Similarity After Cyclic Shifts
This commit is contained in:
46
2946. Matrix Similarity After Cyclic Shifts/Program.cs
Normal file
46
2946. Matrix Similarity After Cyclic Shifts/Program.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
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)}]";
|
||||
}
|
||||
Reference in New Issue
Block a user