Page 1 of 1

O D 1 2 Sub-Grid Given a square grid of integers and an integer value, maxSum, determine the maximum size of the square

Posted: Sun Jul 10, 2022 11:25 am
by answerhappygod
O D 1 2 Sub Grid Given A Square Grid Of Integers And An Integer Value Maxsum Determine The Maximum Size Of The Square 1
O D 1 2 Sub Grid Given A Square Grid Of Integers And An Integer Value Maxsum Determine The Maximum Size Of The Square 1 (58.44 KiB) Viewed 64 times
O D 1 2 Sub Grid Given A Square Grid Of Integers And An Integer Value Maxsum Determine The Maximum Size Of The Square 2
O D 1 2 Sub Grid Given A Square Grid Of Integers And An Integer Value Maxsum Determine The Maximum Size Of The Square 2 (51.82 KiB) Viewed 64 times
O D 1 2 Sub Grid Given A Square Grid Of Integers And An Integer Value Maxsum Determine The Maximum Size Of The Square 3
O D 1 2 Sub Grid Given A Square Grid Of Integers And An Integer Value Maxsum Determine The Maximum Size Of The Square 3 (60.28 KiB) Viewed 64 times
O D 1 2 Sub-Grid Given a square grid of integers and an integer value, maxSum, determine the maximum size of the square sub-grid where for all such sub-grids, the sum of all its elements' values is less than or equal to the value maxSum. Example: grid =[[2, 2, 2], [3, 3, 3], [4, 4, 4]] maxSum: different scenarios shown below maxSum: The maximum sum of all square sub-grids of a size must be less than or equal to this integer value 1. The maximum 1x1 grid has a sum of 4. If maxSum < 4 there is no size square sub-grid that satisfies the condition. The answer is 0. 2 2 2 2 3 3 3 4 4 4 1x1 Sub-grids Maximum sub-grid sum-4 2. The maximum 2x2 grid has a sum of 14. size of the square sub-grid is 1. 2 2 N 2 If 4 s maxSum < 14, the maximum 2: 36 31 32
mum 2x2 grid has a sum of 14. If 4 s maxSum < 14, the maximum size of the square sub-grid is 1. 2 3 4 2 3 4 2 2 3 3 4 4 2 3 4 2 2 32 3 4 2 2 3. 2 3 2 3 3 4 4 4 4 2 x 2 Sub-grids Maximum sub-grid sum = 14 (3+3+4+4=14) 2 2 3 3 4 4 3. The maximum 3x3 grid has a sum of 27. size of the square sub-grid is 2. 4 3x3 Sub-grids Maximum sub-grid sum-27 (2+2+2+3+3+3+4+4+4-27) 2 3 4 2 3 4 12 If 14 s maxSum < 27, the maximum 4. If maxSum 227, the entire grid satisfies the condition so the answer is 3. Vis Test
+ 4 3 x 3 Sub-grids Maximum sub-grid sum=27 (2+2+2+3+3+3+4+4+4=27) 4. If maxSum ≥ 27, the entire grid satisfies the condition so the answer is 3. Function Description Complete the function largestSubgrid in the editor below. largestSubgrid has the following parameter(s): int maxSum: an integer, the maximum acceptable sum of any sub-grid int grid[n][n]: an nx narray where grid[][] is the value of the cell in the throw and th column Returns: should return 0. int: an integer that denotes the largest integer k such that there is no kx ksub-grid with a total value greater than maxSum. If all square sub-grids have value greater than maxSum, the function Constraints 1sns1550 1 s maxSum ≤ 10⁹ 1 ≤ grid[][] ≤ 107 the sum of any entire grid is s 10⁹ Input Format for Custom Testing Sample Case 0 Sample Input 0 STR