MeetCode
Matrix Trace
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
Matrix Trace
Easy
Computer Mathematics
Matrices
33 views
Explanation
Complexity
Problem Statement
Given n and an n x n matrix, print its trace.
Input Format
n then n lines.
Output Format
One integer trace.
Example
Input
2 1 2 3 4
Output
5
Constraints
n
Input / Output Format
Input Format
n then n lines.
Output Format
One integer trace.
Constraints
n
Examples
Input:
2 1 2 3 4
Output:
5
Example Solution (Public)
Computer Mathematics
Sum diagonal elements a[i][i].
Official Solution Code
Wrap
Copy
Sum diagonal elements a[i][i].
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
2 1 2 3 4
Expected Output
5
Compile Output
Error
Output
Please
login
to submit solutions.