We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Greedy
- Max Min
- Discussions
Max Min
Max Min
Sort by
recency
|
883 Discussions
|
Please Login in order to post a comment
Java:
def maxMin(k, arr): return min(map(lambda x, y: abs(x - y), sorted(arr)[:-k + 1], sorted(arr)[k - 1:]))
JS
Java Solution
Two pointer approach