Clean Python 3, generator with deque
Time: O(sort), it can reach O(N) if we adopt counting sort\nSpace: O(N) for output\nThanks grokus for his suggestion.\n\nimport collections\nclass Solution:\n  
Time: `O(sort)`, it can reach O(N) if we adopt counting sort\nSpace: `O(N)` for output\nThanks [grokus](https://leetcode.com/grokus/) for his suggestion.\n```\nimport collections\nclass Solution:\n    def getStrongest(self, arr: List[int], k: int) -> List[int]:\n        def gen(A):\n            dq = collections.deque(A)\n            n = len(dq)\n            m = dq[(n - 1) // 2]\n            for _ in range(k):\n                front, tail = m - dq[0], dq[-1] - m\n                if front > tail:\n                    yield dq.popleft()\n                else:\n                    yield dq.pop()\n        return list(gen(sorted(arr)))\n```
[]