← TCS questions

Diagonal Sum in 2D Matrix

Filed under TCS

Given a square matrix 'mat', return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related TCS questions

Collected from public candidate posts and coding forums. Updated Nov 2026.