Help with Time Complexity of a Problem.


. Let's define an array B as S concatenated with itself m times, where m is the smallest integer such that m(r−l+1)≥K
. Next, let's sort B and define X=BK, i.e. as a K-th smallest element of B. Note that |B|≥K.

Are you actually generating B and sorting it?

Because I think you only need to sort S, and do a bit of math.

Also, post your code.
post your code.
closed account (Nhf30pDG)
Even sorting S after each iteration would time out.You need to observe some pattern in the Q.Post your code let us see what u did.
dave please explain what is Q in "You need to observe some pattern in the Q"
Topic archived. No new replies allowed.