Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Ones

med
30 min
Try to solve the Maximum Number of Ones problem.

Statement

Consider a binary matrix with dimensions width and height. You are also given an integer sideLength representing the side length of a square subgrid, and an integer maxOnes.

Return the maximum number of ones that can be placed in the matrix such that every square subgrid of size sideLength by sideLength contains at most maxOnes ones.

Constraints:

  • 1≤1 \leq width, height ≤100\leq 100

  • 1≤1 \leq sideLength ≤\leq width, height

  • 0≤0 \leq maxOnes ≤\leq sideLength $ imes$ sideLength

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Ones

med
30 min
Try to solve the Maximum Number of Ones problem.

Statement

Consider a binary matrix with dimensions width and height. You are also given an integer sideLength representing the side length of a square subgrid, and an integer maxOnes.

Return the maximum number of ones that can be placed in the matrix such that every square subgrid of size sideLength by sideLength contains at most maxOnes ones.

Constraints:

  • 1≤1 \leq width, height ≤100\leq 100

  • 1≤1 \leq sideLength ≤\leq width, height

  • 0≤0 \leq maxOnes ≤\leq sideLength $ imes$ sideLength