DEV Community

Debesh P.
Debesh P.

Posted on

Summed Matrix | GeeksforGeeks‬ Beginner's DSA Sheet | Matrix Problems | With Source Code

hola coders!

In this video, I’ll teach you how to solve the Summed Matrix problem from GeeksforGeeks step by step. If you’ve ever struggled with matrix-based problems, this tutorial is for you!


Problem Link: https://www.geeksforgeeks.org/problems/summed-matrix5834/1

Source Code: https://github.com/debeshp6/Gfg-Tutorials/blob/main/SummedMatrix.java


Code

class Solution { static long sumMatrix(long n, long q) { // code here if(q < 2 || q > n * 2) { return 0; } if(q <= n + 1) { return q - 1; } else { return n - (q - n -1); } } } 
Enter fullscreen mode Exit fullscreen mode

Matrix problems are common in coding interviews, competitive programming, and even real-world applications. Learning this concept will boost your problem-solving skills and help you tackle similar problems easily!

Got any doubts? Drop your questions in the comments, and I'll help you out.

happy coding!

Top comments (0)