Given $N$ points in a grid having some weight, I have to find the side length of a square sub-grid with maximum sum of weight of points contained in that square sub-grid. Also square sub-grid must have side length less than $L$ (given integer).
$ 1\le N \le 100000$, $1 \le L \le 100000$ , $1 \le x_i \le100000$, $1 \le y_i \le 100000$, $1 \le \text{weight}_i \le 10^9$, where $i$ is the $i^{th}$ point.
I have tried using prefix sum array and iterating over all the possible square sub-grids, but this is not efficient.
I need to know in which direction should I start thinking.
