Search
⌘K

Leetcode 3242. Design Neighbor Sum Service

Given an n×n grid of distinct values, implement a class that answers queries returning the sum of either orthogonally adjacent (top/left/right/bottom) or diagonal neighbors of a given value. Because values are unique and there can be many queries, precomputing a value→(row,col) mapping for O(1) lookups is expected.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.