Loading...

Diagonal Extract

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium

Problem

We store correlation matrices as lists of lists and sometimes need just the diagonal for dimensionality checks. Extract the main diagonal (the values where the row index equals the column index) and return them as a flat list.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.