Round 1
Questions:
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, _]
Candidate's Approach
Started with brute force, asked to run the code, talked about time complexity. Gave me a couple of pointers, but I couldn't solve it the most optimal way.
Interviewer's Feedback
No feedback provided.