Java solution | Two approaches
Please Upvote !!!\n##### 1. Using Priority Queue (Max Heap)\n\nclass Solution {\n    public int[] getStrongest(int[] arr, int k) {\n        Arrays.sort(arr);\n 
### *Please Upvote !!!*\n##### 1. Using Priority Queue (Max Heap)\n```\nclass Solution {\n    public int[] getStrongest(int[] arr, int k) {\n        Arrays.sort(arr);\n        int m = arr[(arr.length - 1) / 2];\n        PriorityQueue<Integer> pq = new PriorityQueue<>(\n                (a, b) -> Math.abs(a - m) == Math.abs(b - m) ? b - a : Math.abs(b - m) - Math.abs(a - m)\n        );\n\n        for (int num : arr) {\n            pq.offer(num);\n        }\n\n        int[] ans = new int[k];\n        for (int i = 0; i < k; i++) {\n            ans[i] = pq.poll();\n        }\n\n        return ans;\n    }\n}\n\n// TC: O(n * logn) + O(n) => O(n * logn)\n// SC: O(n + k)\n```\n##### 2. Two Pointer approach (faster)\n```\nclass Solution {\n    public int[] getStrongest(int[] arr, int k) {\n        Arrays.sort(arr);\n        int m = arr[(arr.length - 1) / 2];\n        int[] ans = new int[k];\n        int left = 0, right = arr.length - 1;\n        int index = 0;\n\n        while (index < k) {\n            if (m - arr[left] > arr[right] - m) {\n                ans[index++] = arr[left++];\n            } else {\n                ans[index++] = arr[right--];\n            }\n        }\n\n        return ans;\n    }\n}\n\n// TC: O(n * logn) + O(k) => O(n * logn)\n// SC: O(k)\n```
['Two Pointers', 'Heap (Priority Queue)', 'Java']