← Microsoft questions

Calculate sum of elements in a submatrix rectangle

Filed under Microsoft

Given an m x n matrix, calculate the sum of elements within a sub-rectangle defined by (r1, c1) and (r2, c2). Provide solutions for: 1) Single query, 2) Frequent queries with no updates, and 3)…

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 Microsoft questions

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