bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
HardGreedyLC 1183

Maximum Number of Ones

Consider a matrix M with dimensions width height, such that every cell has value 0 or 1, and any square sub-matrix of M of size sideLength sideLength has at most maxOnes ones. Return the maximum possible number of ones that the matrix M can have.

Asked at 1 company
Qualcomm
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode