2946. Matrix Similarity After Cyclic Shifts

This commit is contained in:
2026-03-30 11:17:12 +03:00
parent 2cac465442
commit 556eecbe21
4 changed files with 90 additions and 0 deletions

View 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)}]";
}