v1 time O(nlog(n)) space O(log(n)) Accepted

master method