PayPal | OA | Largest Sub-Grid: 2D Prefix Sums and Binary Search

PayPal · Question · Posted Apr 2026

Problem Statement: Largest Sub-Grid The Objective: You are given an n×n square grid of integers and an integer value, maxSum. Your task is to determine the maximum possible size k (0≤k≤n) of a square sub-grid such that all possible k×k sub-grids within the original grid have a total sum less than or equal to maxSum. Key Constraints: If even the smallest possible square sub-grid (1×1) has an element greater than maxSum, the answer is 0. You must find the largest ...

The full answer & interview discussion are available to premium members.

Log in Create a free account