This is real nlogn way
Added changes