From eddb4c1a5558b94484d616eb85add77759ee71b0 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Wed, 13 Dec 2023 18:06:57 +0100 Subject: [PATCH] =?UTF-8?q?problems(swift):=20add=20=E2=80=9C1582.=20Speci?= =?UTF-8?q?al=20Positions=20in=20a=20Binary=20Matrix=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej Focko --- ...special-positions-in-a-binary-matrix.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 swift/special-positions-in-a-binary-matrix.swift diff --git a/swift/special-positions-in-a-binary-matrix.swift b/swift/special-positions-in-a-binary-matrix.swift new file mode 100644 index 0000000..a8f8a32 --- /dev/null +++ b/swift/special-positions-in-a-binary-matrix.swift @@ -0,0 +1,25 @@ +class Solution { + func numSpecial(_ mat: [[Int]]) -> Int { + let m = mat.count + let n = mat[0].count + + var rows: [Int] = Array(repeating: 0, count: m) + var cols: [Int] = Array(repeating: 0, count: n) + + for (y, x) in (0..