MPHASIS Trainee Engineer | Matrix Pattern Analysis & Text Compression | OA Questions (2023 to 2024)

Question · Posted Jun 2026

Q1. Matrix Cross-Sum Calculation Problem Statement Given a square matrix, calculate the sum of elements present on: The primary diagonal The secondary diagonal If the matrix has an odd dimension, the center element belongs to both diagonals and should be counted only once. Return the final diagonal sum. Example Input matrix = [  [1,2,3],  [4,5,6],  [7,8,9] ] Output 25 Explanation Primary diagonal: 1 + 5 + 9 = 15 Secondary diagonal: 3 + 5 + 7 = 15 Center element: ...

The full answer & interview discussion are available to premium members.

Log in Create a free account