How to solve this problem in O(log(n)*n) or less?

Revision en2, by pretending, 2021-07-17 17:03:05

I am stuck at this problem currently.

Problem link

I have tried a O(n^2) approach but the accepted solution is supposedly O(log(n)*n) or less. How do solve this?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English pretending 2021-07-17 17:03:05 755
en1 English pretending 2021-07-17 14:22:43 1016 Initial revision (published)