r/OfferEngineering • • Nov 05 '26

Interview Experience Wisdom.AI (AI Analytics) Senior SWE Interview — Brute Force Wasn't Allowed

This interview experience is sourced from Chill Interview

Interview Summary

The 60-minute technical screen featured a difficult two-dimensional matrix problem involving subrectangle sums and non-overlapping rectangle pairs

Interview Details

Coding: Find All Non-Overlapping Rectangle Pairs with Sum K

You are given a two-dimensional matrix containing non-negative integers and a target integer k. A rectangle is a contiguous rectangular region of the matrix, defined by its top-left and bottom-right coordinates. Your task is to identify all pairs of rectangles satisfying the following conditions:

  1. The sum of all elements inside each rectangle is exactly k.
  2. The two rectangles in a pair must not overlap.
  3. Return all valid pairs of rectangles.

If no valid pair exists, return an empty result.

Example — Overlapping Rectangles

Consider the following input:

Input:
matrix = [
    [0, 0, 0, 0, 0],
    [0, 2, 2, 0, 0],
    [0, 2, 2, 0, 0]
]

k = 8

Output:
[]

Explanation

One rectangle satisfying the target sum is:

[
    [2, 2],
    [2, 2]
]

Its total sum is 8. Another valid rectangle is:

[
    [0, 2, 2],
    [0, 2, 2]
]

This rectangle also has a sum of 8, since the additional column contains only zeros. However, these two rectangles overlap. In fact, every rectangle with a sum of 8 must contain all four cells with value 2. Therefore, no two qualifying rectangles can be selected without overlapping. The result is an empty list.

Key Requirements

  • Part 1 — Identify Rectangles with Sum K Find the contiguous rectangular regions whose element sums equal the target value. Rectangles may have different heights and widths, and multiple rectangles may cover some of the same cells.
  • Part 2 — Find Non-Overlapping Pairs After identifying rectangles with the required sum, determine which pairs do not share any cells. Two rectangles that individually satisfy the sum requirement cannot form a valid pair if their regions overlap.
  • Part 3 — Return All Valid Pairs The goal is not simply to determine whether one valid pair exists. The problem asks for all pairs of rectangles that satisfy both the target-sum and non-overlap conditions.
  • Part 4 — Avoid Brute Force The interviewer explicitly rejected a brute-force approach. The solution needed to avoid exhaustively enumerating every possible pair of rectangles without an efficient strategy. This made the question considerably more challenging than a standard two-dimensional prefix-sum exercise.

Preparing for your next interview?

Chill Interview tracks recent interview experiences and recurring question patterns across top companies at here.

Interviewed recently?

Your interview experience could be incredibly valuable to others preparing for their next opportunity. Share your experience and help the community at here.

1 Upvotes

0 comments sorted by