What you are looking for : 100% time and space beat
Intuition
Just thinking in which way the addition process would be the simplest.
Should I use two iterators ?
Approach
Approach is simple. First identified whic
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
- ****Just thinking in which way the addition process would be the simplest.**
Should I use two iterators ?**

---

# Approach
<!-- Describe your approach to solving the problem. -->
- **Approach is simple. First identified which are the indices I want to include. Then using relation betwen the two iterators, We get the result.**
- **But wait , in this process the median index will be counted two times for an odd length list. That's why we've used a subtraction to correct the overcalculation**



![Gemini_Generated_Image_dd1cg9dd1cg9dd1c.jpg](https://assets.leetcode.com/users/images/7e0defed-8e1b-466a-b5d9-498d07a4a31a_1742588356.7863743.jpeg)



# Complexity


- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(n)$$
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$$O(1)$$
# Code
```python []
class Solution(object):
    def diagonalSum(self, mat):
        n = len(mat)
        result = 0
        for i in range(n) :
            result += mat[i][i]
            result += mat[i][n-1-i]
        if n%2 == 1 :
            result -= mat[int(n/2)][int(n/2)]
        return result

        
```
['Python']