+ import std.math; import std.typecons; - import std.math; /* - - Given an array arr of integers and a positive integer k, return a sorted array ? ---- + Given an array arr of integers and a positive integer k, return a sorted array - of length k with the maximum k numbers in arr. ? ---- + of length k with the maximum k numbers in arr. - - Example 1: ? ---- + Example 1: - - >>> maximum([-3L, -4L, 5L], 3L) ? ---- + >>> maximum([-3L, -4L, 5L], 3L) - [-4L, -3L, 5L] ? ---- + [-4L, -3L, 5L] - - Example 2: ? ---- + Example 2: - - >>> maximum([4L, -4L, 4L], 2L) ? ---- + >>> maximum([4L, -4L, 4L], 2L) - [4L, 4L] ? ---- + [4L, 4L] - - Example 3: ? ---- + Example 3: - - >>> maximum([-3L, 2L, 1L, 2L, -1L, -2L, 1L], 1L) ? ---- + >>> maximum([-3L, 2L, 1L, 2L, -1L, -2L, 1L], 1L) + [2L] + Note: - [2L] - - Note: - 1. The length of the array will be in the range of [1, 1000]. ? ---- + 1. The length of the array will be in the range of [1, 1000]. - 2. The elements in the array will be in the range of [-1000, 1000]. ? ---- + 2. The elements in the array will be in the range of [-1000, 1000]. - 3. 0 <= k <= len(arr) ? ---- + 3. 0 <= k <= len(arr) - */ long[] maximum(long[] arr, long k)