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