Java || O(NlogN) || Single Sort || Two Pointer
Once the array is sorted, use the fact that smallest and largest element is going to have the largest absolute difference with the median.\n\n\nclass Solution {
Once the array is sorted, use the fact that smallest and largest element is going to have the largest absolute difference with the median.\n\n```\nclass Solution {\n    public int[] getStrongest(int[] arr, int k) {\n        int n = arr.length;\n        \n        Arrays.sort(arr);\n        \n        int m = arr[(n-1)/2];\n        \n        int[] res = new int[k];\n        \n        int st = 0;\n        int ed = n-1;\n        int i = 0;\n        \n        while(st <= ed && i < k){\n            int a = Math.abs(arr[st] - m);\n            int b = Math.abs(arr[ed] - m);\n            \n            if(a > b){\n                res[i] = arr[st];\n                st++;\n            } else if(b > a){\n                res[i] = arr[ed];\n                ed--;\n            } else {\n                if(arr[st] > arr[ed]){\n                    res[i] = arr[st];\n                    st++;\n                } else {\n                    res[i] = arr[ed];\n                    ed--;\n                }\n            }\n            \n            i++;\n        }\n        \n        return res;\n    }\n}\n```
[]