Range Sum Query 2D - Immutable | Prefix Sum on Matrix | Dp | 304 LeetCode | Day 12

preview_player
Показать описание
Here is the detailed solution of LEETCODE DAY 12 RANGE SUM QUERY 2D IMMUTABLE Problem of May Leetcoding Challenge and if you have any doubts , do comment below to let us know and help you.

In this Video, I have discussed the best solution for the problem. I have
explained how to compute the prefix sum on matrix and answer for every query in O(1) with some prerequisite calculation.

Any suggestions are welcomed, and do subscribe to my YouTube Channel for latest updates for solutions as well as explanations.

You can donate to support us :-

Timestamps:-
Introduction:- 00:00
Problem Statement:- 00:14
Explanation With Example:- 02:10
Explanation in detail:- 07:47
Code:- 12:50

Link to Code:-

Complete May LeetCoding Challenge Playlist:-

Complete April LeetCoding Challenge Playlist:-

Complete March LeetCoding Challenge Playlist:-

Follow me on LinkedIn:-

Join my Telegram Channel:-
Рекомендации по теме
Комментарии
Автор

Since we are given the start and endpoint of the rectangle and we know the size of the matrix can't we iterate the rows and cols until the endpoint and sum the elements? For example, the start (1, 1) and end (2, 3) size of the matrix is 4 x 5. Then indices are row = 1, 2 and cols = 1, 2, 3 so we will have (1, 1) (1, 2) (1, 3) and (2, 1) (2, 2) (2, 3) since we hit the end return the sum of indices. Can't this be done in constant time

er-wlsy
welcome to shbcf.ru