Given an array $S$ of length $n$ and an integer $k$. Find maximum value of $(r-l+1)$ such that $\prod_{i=l}^{r}{S_{i}} \le k$ Constraints click to hide $1\le n \le 10^{5}$ $0\le k \le 10^{9}$ $0\le S_{i} \le 10^{9}$ Bruteforce Solution $O(n^2)$: If any value of $S$ is $0$ then the answer is $n$ We call a segment $[l,r]$ valid if $\prod_{i=l}^{r}{S_{i}} \le k$