← Amazon questions

Submatrix sum queries in O(1)

Filed under Amazon

Given a 2D matrix of size M x N, implement a data structure or preprocessing method to answer a large number of queries asking for the sum of elements within any submatrix defined by top-left (r1, c1)…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.