The problem is this.
I guess it is a common problem. I have tried it solving with binary search.
My Approach
Python Code
Difficulty — TLE
Help Needed — I know python is slow, but there are many peoples solving it with python. My question is how this code can be optimized (especially the valid function taking O(n*k) operations)?
I have seen the editorial, using other methods. But I am learning how to implement binary search, that is why I am trying this way.
Thanks for taking the time for reading this!
UPDATE: Accepted