1572 Matrix Diagonal Sum | Zero to FAANG Kunal | Assignment Solution | Leetcode

preview_player
Показать описание
1773 Count Items Matching a Rule | Zero to FAANG Kunal | Assignment Solution | Leetcode

Problem link :

Course link:

Complete Java + DSA + Interview Preparation + CP Course

Hi, thanks for watching our video about 2D Arrays in Java
In this video we’ll walk you through:
- Brute Force
- Efficient approach
- Solution Code

TIMESTAMPS
Intro
Explanation begins
IDE solution

ABOUT OUR CHANNEL
Our channel is all about Programming. We cover lots of cool stuff such as solution to problems, concept explanation and tricks to master CP
Check out our channel here:
Don’t forget to subscribe!

CHECK OUT OUR OTHER Playlists

GeeksforGeeks playlist:

Complete C++ Course playlist:

CodeChef Playlist:

HackerRank playlist:

LeetCode problems

FIND US AT

GET IN TOUCH

1572. Matrix Diagonal Sum

Easy

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 of the primary diagonal.



Example 1:

Input: mat = [[1,2,3],
[4,5,6],
[7,8,9]]
Output: 25
Explanation: Diagonals sum: 1 + 5 + 9 + 3 + 7 = 25
Notice that element mat[1][1] = 5 is counted only once.
Example 2:

Input: mat = [[1,1,1,1],
[1,1,1,1],
[1,1,1,1],
[1,1,1,1]]
Output: 8
Example 3:

Input: mat = [[5]]
Output: 5


Constraints:

1 = n = 100
1 = mat[i][j] = 100
Accepted
65,882
Submissions
84,229

#codechef #coding #python #hackerrank #programming #java #computerscience #coder #code #competitiveprogramming #machinelearning #pythonprogramming #algorithms #cpp #javascript #hackerearth #webdeveloper #geeksforgeeks #codinglife #leetcode #c #codeforces #engineering #codingmemes #programmer #hacker #programmingmemes #topcoder #webdevelopment #bhfyp #DSAwithKunal
Рекомендации по теме
Комментарии
Автор

Huge respect sir your explanation for the solution is just awesome and also a huge thank you for showing the C++ Code too huge respect sir 👏 will surely recommend your channel if anyone of my friend using C++ faces any difficulty in solving any leetcode problem

Thank you sir

vedantoza
Автор

Very easy bro
i make very different way to solve but every time got new errors when matrix increase their length
-my code not inhanced for increasing length of elements thanks got new lesson.

dynamokumar
Автор

Great explanation🤩. Thank you so much.

someone-qmju
Автор

Thank you so much bro, can you tell me how to think the approach of the problem. The way you taught really helped me.

sabujdeeptudu
Автор

Good explanation bro bs ye mat[n-1-i] wla logic nhi samajh aaya ? Bata do koi agar janta hai toh

abhishekkr
Автор

Secondary diagonal ka logic nahi samjh aa raha hai [n-i-1] and what is n here... And please explain use of mat.length

soulcalculas
Автор

if you try to explain in english it will better to us

bandaruneeraj
Автор

bhai mere ghar se pen paper le ja par writing improve kar kuch nahi saf dekh ta

ashugupta
Автор

bhai english bolna seekhle nhi toh hindi toh dhang se bol liya kar

charviverma
welcome to shbcf.ru