LeetCode Question · Jan 2025 · Los Angeles

Snap phone screen | L5 | Reject

SWE Phone Screen Senior
4 upvotes 427 views 7 replies

Question Details

Hi, I had a phone screen with snap today. Here is the question i was asked. Image region with sum Write code which determines whether the sum of all elements in a...

Full Details

Hi, I had a phone screen with snap today. Here is the question i was asked.

Image region with sum

Write code which determines whether the sum of all elements in a rectangular area
in a square 2d array are equal to a target, and if true, prints out the coordinates
(top left and bottom right) of a rectangular area which has the target sum.

**Constraints**:
- All elements in the array are positive
- The input array is valid (e.g all rows have the same length)
- If there are multiple solutions, any one is valid, don\'t need to find all

**Example 1**:

**Input** array:
[2, 6, 4]
[8, 3, 1]
[4, 5, 2]
Target:
20

**Output**:
[1,0], [2,1]
This region sums to 20:
[_, _, _]
[8, 3, _]
[4, 5, _]

Started with brute force, asked to run the code, Talked about time complexity.
Gave me couple of pointers, but i counldn\'t solve it the most optimal way.

I guess i need to prepare more.

About This Question

This is a reported interview question from a snap interview for a swe role (senior level) during the phone screen round reported in 2025.

It covers the following topics: Arrays, Matrix .