The TransCompilator

Solved LeetCode program · 929 of 1,000

#1292 · Maximum Side Length of a Square with Sum Less than or Equal to Threshold

Medium Array chunk-19.md

Original English source

The cells is a list of 1, 1, 3, 2, 4, 3, 2, 1, 1, 3, 2, 4, 3, 2, 1, 1, 3, 2, 4, 3, and 2. The height is 3. The width is 7. The threshold is 4. The answer is 0.
For every side from 1 to 3.
The possible is 0.
For every top from 0 to height minus side.
For every first from 0 to width minus side.
The total is 0.
For every down from 0 to side minus 1.
For every second from 0 to side minus 1.
The spot is (top plus down) times width plus first plus second. Increase total by item spot of cells. If down is side minus 1 and second is side minus 1 and total is at most threshold, set possible to 1. If possible is 1, set answer to side.

Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

2