v10 time O(nklog(k)) space O(nk) Accepted

the initial analysis was wrong which wasted a lot of time and tries

another mistake which wasted a lot of tries is that ArrayDeque doesn't accept null