From 18b59649a663d189d9b264f86b1f7466d7f96a86 Mon Sep 17 00:00:00 2001 From: ductnn Date: Sun, 10 Dec 2023 22:34:42 +0700 Subject: [PATCH] add sol --- .../equalRowAndColumnPairs.go | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 leetcode/leetcode75/2352.EqualRowAndColumnPairs/equalRowAndColumnPairs.go diff --git a/leetcode/leetcode75/2352.EqualRowAndColumnPairs/equalRowAndColumnPairs.go b/leetcode/leetcode75/2352.EqualRowAndColumnPairs/equalRowAndColumnPairs.go new file mode 100644 index 0000000..70692f7 --- /dev/null +++ b/leetcode/leetcode75/2352.EqualRowAndColumnPairs/equalRowAndColumnPairs.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" +) + +func equalPairs(grid [][]int) int { + result := 0 + for i := range grid { + for j := range grid { + ok := 1 + for k := range grid { + if grid[i][k] != grid[k][j] { + ok = 0 + break + } + } + result += ok + } + } + return result +} + +func main() { + grid := [][]int{{3, 1, 2, 2}, {1, 4, 4, 5}, {2, 4, 2, 2}, {2, 4, 2, 2}} + fmt.Print(equalPairs(grid)) +}