The Diagonal Accountant
A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L3
Problem
Given an n x n matrix, return the sum of main-diagonal and anti-diagonal values. For odd n, do NOT double-count the center element.
Summary
Two diagonals cross in the center of every square.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.