Can someone please give me some hints to solve this problem. Thanks in Advance!!
isn't this a o(n logn) solution ?