0

Given an $m\times n$ matrix $M_{ij}$ where $M_{ij}\in\{0,1\}$, find the minimal range $[a,b]$ for $1 \leq a \leq b \leq m$ such that each column has at least one value set to $1$ within that window, i.e. $\sum_{i=a}^bM_{ij} \geq 1$ for each $j \in \{1\dots n\}$.

I have come across this real-world problem that I have been struggling to find an efficient solution for. Is there an efficient solution for this problem or, if not, are there techniques to find a good approximation? I would be very grateful for any advice.

fekr
  • 1
  • 2
  • a trivial solution is to verify for each possible value of $a$ and $b$; there are $m^2$ such combinations; thus $O(m^3 \cdot n)$ running time. Are you looking for a better running time? – Inuyasha Yagami Oct 24 '23 at 20:25
  • @InuyashaYagami Yes, you are right. I fixed it, thank you. And yes, I was wondering if there is some way to improve on the running time of the trivial solution you described. Also, this post seems to be a broader definition of the same problem so I will flag this as a duplicate. – fekr Oct 24 '23 at 22:47

0 Answers0