Trains the technique from
LeetCode 3567Minimum Absolute Difference in Sliding SubmatrixThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A board of readings is given as grid.
For every k by k window of the board, report the smallest positive difference between two readings inside it, or 0 when every reading in that window is the same.
Return those figures as a board of their own, laid out so that the entry at row i and column j answers the window whose top-left corner sits at row i, column j.
Example 1
The top-left window holds 14, 3, 9 and 21; in order those are 3, 9, 14 and 21, and the closest neighbours are 9 and 14, five apart. The other three windows are read the same way.
Example 2
The single window holds one distinct reading, so there is no pair to measure.
Example 3
Every window is a single cell, so none of them holds a pair.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def min_abs_diff(grid: list[list[int]], k: int) -> list[list[int]]:public int[][] minAbsDiff(int[][] grid, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.