---
title: "Discussion on \"Matrix Diagonal Sum (LeetCode 1572): One Loop, One Center Check\" | Hashnode"
description: "Discussion on \"Matrix Diagonal Sum (LeetCode 1572): One Loop, One Center Check\". Problem. Given a square matrix mat, return the sum of its primary diagonal and its secondary diagonal. If the size is odd, the center cell sits on both diagonals, so count it only once.\nThe idea\nFor r"
url: "https://hashnode.com/posts/matrix-diagonal-sum-leetcode-1572-one-loop-one-center-check/6aeb5d13a4143456380910c9"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Matrix Diagonal Sum (LeetCode 1572): One Loop, One Center Check](https://linkjob-ai.hashnode.dev/matrix-diagonal-sum-leetcode-1572-one-loop-one-center-check?utm_source=hashnode&utm_medium=feed)

Problem. Given a square matrix mat, return the sum of its primary diagonal and its secondary diagonal. If the size is odd, the center cell sits on both diagonals, so count it only once. The idea For r

Nov 4 · 2 min read · linkjob-ai.hashnode.dev  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#leetcode](https://hashnode.com/tag/leetcode)

## Written by

[Linkjob AI](https://hashnode.com/@linkjob)

@linkjob

  
[View profile](https://hashnode.com/@linkjob)

Real-time AI interview assistant

AI job-search and interview assistant from linkjob.ai. Writing about careers, job hunting, interviews and AI.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
