[Question]
  [
Consider an array `x` such as `[1 5 3 4]` and a number `n`, for example `2`. Write all length-`n` sliding subarrays: `[1 5]`, `[5 3]`, `[3 4]`. Let the *minimax* of the array be defined as the minimum of the maxima of the sliding blocks. So in this case it would be the minimum of `5, 5, 4`, which is `4`.
## Challenge
Given an array `x` and a positive integer `n`, output the minimax as defined above.
The array `x` will only contain positive integers. `n` will always be at least `1` and at most the length of `x`.
Computation may be done by any procedure, not necessarily as defined above.
Code golf, fewest bytes wins.
## Test cases
`x`, `n`, result
```
[1 5 3 4], 2                    4
[1 2 3 4 5], 3                  3
[1 1 1 1 5], 4                  1
[5 42 3 23], 3                 42
```
  
[Answer]
# Dyalog APL, 4 bytes
```
⌊/⌈/
```
This is a monadic function train that expects array and integer as right and left arguments, resp.
Try it with [TryAPL](http://tryapl.org/?a=2%20%28%u230A/%u2308/%29%201%205%203%204&run).
### How it works
A train of two functions is an *atop*, meaning that the right one is called first (with both arguments), then the left one is called on top of it (with the result as sole argument).
A monadic `f/` simply reduces its argument by `f`. However, if called dyadically, `f/` is n-wise reduce, and takes the slice size as its left argument.
```
⌊/⌈/    Monadic function. Right argument: A (array). Left argument: n (list)
  ⌈/    N-wise reduce A by maximum, using slices of length n.
⌊/      Reduce the maxima by minimum.
```
[Answer]
## CJam (11 bytes)
```
{ew::e>:e<}
```
[Online demo](http://cjam.aditsu.net/#code=%5B1%201%201%201%205%5D%204%0A%0A%7Bew%3A%3Ae%3E%3Ae%3C%7D%0A%0A~)
[Answer]
# Ruby 39 bytes
```
->(x,n){x.each_slice(n).map(&:max).min}
```
Where x is the array and n is the number to chunk the array by.
[Answer]
# Oracle SQL 11.2, 261 bytes
```
SELECT MIN(m)FROM(SELECT MAX(a)OVER(ORDER BY i ROWS BETWEEN CURRENT ROW AND :2-1 FOLLOWING)m,SUM(1)OVER(ORDER BY i ROWS BETWEEN CURRENT ROW AND:2-1 FOLLOWING)c FROM(SELECT TRIM(COLUMN_VALUE)a,rownum i FROM XMLTABLE(('"'||REPLACE(:1,' ','","')||'"'))))WHERE:2=c;
```
Un-golfed
```
SELECT MIN(m)
FROM   (
         SELECT MAX(a)OVER(ORDER BY i ROWS BETWEEN CURRENT ROW AND :2-1 FOLLOWING)m,
                SUM(1)OVER(ORDER BY i ROWS BETWEEN CURRENT ROW AND :2-1 FOLLOWING)c
         FROM   (
                  SELECT TRIM(COLUMN_VALUE)a,rownum i 
                  FROM XMLTABLE(('"'||REPLACE(:1,' ','","')||'"'))
                )
       )
WHERE :2=c;
```
[Answer]
## Pyth, 10 bytes
```
hSmeSd.:QE
```
Explanation:
```
           - autoassign Q = eval(input())
      .:QE -   sublists(Q, eval(input())) - all sublists of Q of length num
  meSd     -  [sorted(d)[-1] for d in ^]
hS         - sorted(^)[0]
```
Takes input in the form `list newline int`
[Try it here!](http://pyth.herokuapp.com/?code=hSmeSd.%3AQE&input=%5B1%2C+5%2C+3%2C+4%5D%0A2&debug=0)
[Or run a Test Suite!](http://pyth.herokuapp.com/?code=hSmeSd.%3AQE&input=%5B1%2C+5%2C+3%2C+4%5D%0A2&test_suite=1&test_suite_input=%5B5.4%2C+-3.4%2C+6.7%2C+8.8%2C+-1.2%5D%0A3%0A%5B-1%2C+2%2C+-3%2C+4%2C+-5%5D%0A2%0A%5B-1%2C+2%2C+4%2C+-3%2C+-5%5D%0A2%0A%5B0.2%2C+4.5%2C+3.4%2C+2.3%5D%0A4%0A&debug=0&input_size=2)
### Or also 10 bytes
```
hSeCSR.:EE
```
Explanation:
```
      .:EE -    sublists(Q, eval(input())) - all sublists of Q of length num 
    SR     -   map(sorted, ^)
  eC       -  transpose(^)[-1]
hS         - sorted(^)[0]
```
[Test Suite here](http://pyth.herokuapp.com/?code=hSeCSR.%3AEE&input=%5B1%2C+5%2C+3%2C+4%5D%0A2&test_suite_input=%5B5.4%2C+-3.4%2C+6.7%2C+8.8%2C+-1.2%5D%0A3%0A%5B-1%2C+2%2C+-3%2C+4%2C+-5%5D%0A2%0A%5B-1%2C+2%2C+4%2C+-3%2C+-5%5D%0A2%0A%5B0.2%2C+4.5%2C+3.4%2C+2.3%5D%0A4%0A&debug=0&input_size=2)
[Answer]
# Jelly, 6 bytes
```
ṡ»/€«/
```
[Try it online!](http://jelly.tryitonline.net/#code=4bmhwrsv4oKswqsv&input=&args=WzEsIDUsIDMsIDRd+Mg)
### How it works
```
ṡ»/€«/  Main link. Left input: A (list). Right input: n (integer)
ṡ       Split A into overlapping slices of length n.
 »/€    Reduce each slice by maximum.
    «/  Reduce the maxima by minimum.
```
[Answer]
# JavaScript (ES6), ~~84~~ ~~83~~ 72 bytes
```
(x,y)=>Math.min(...x.slice(y-1).map((a,i)=>Math.max(...x.slice(i,i+y))))
```
Thanks to user81655 for helping shave off 11 bytes
[Answer]
# [Perl 6](http://perl6.org), 32 bytes
```
{@^a.rotor($^b=>1-$b)».max.min}
```
### Usage:
```
my &minimax = {@^a.rotor($^b=>1-$b)».max.min}
say minimax [1,5,3,4], 2;    # 4
say minimax [1,2,3,4,5], 3;  # 3
say minimax [1,1,1,1,5], 4;  # 1
say minimax [5,42,3,23], 3;  # 42
```
[Answer]
# R, ~~41~~ 35 bytes
Requires zoo to be installed.
```
function(x,n)min(zoo::rollmax(x,n))
```
*edit* - 6 bytes by realizing `zoo::rollmax` exists!
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 4 bytes
```
lvGg
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJsdkdnIiwiIiwiM1xuWzEsIDIsIDMsIDQsIDVdIl0=)
Why reduce by things when you can just vectorise.
## Explained
```
lvGg
l    # overlaps of input list of size input integer. 
 vG  # maximum of each window
   g # minimum of that
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
```
▼m▲X
```
[Try it online!](https://tio.run/##yygtzv7//9G0PbmPpm2K@P//v/H/aEMdIx1jHRMd01gA "Husk – Try It Online")
### Explanation
```
▼m▲X
   X  each consecutive slice of length
 m▲   maximum of each
▼     minimum
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
ṡṀ€Ṃ
```
[Try it online!](https://tio.run/##y0rNyan8///hzoUPdzY8alrzcGfT/8PLlSL//4821FEw1VEw1lEwidVRAPGMIDygMFQAjsACQMUmECVGxrH/4YqNAQ "Jelly – Try It Online")
Since [Dennis' answer](https://codegolf.stackexchange.com/a/73187/66833), the `Ṁ`aximum and `Ṃ`inimum monadic atoms have been added
[Answer]
# [Julia 0.6](http://julialang.org/), 51 bytes
```
f(x,n)=min([max(x[i-n+1:i]...)for i=n:endof(x)]...)
```
[Try it online!](https://tio.run/##bczBCoMwDAbgu08R8JIyJ9jWHQSfpHjosEJGjVK34dt37bw2uYQ/H//r48k@YlzwbFiMKzGa1Z54GrrzrRtoattWLFsAGnlwPG9Jin8Yc@qJHRBDcHbO94GigjS2ecII7ms97jYcDvNTXL89EL8944JJpSy1RtNBDwr01ICEwtS6SkRmAn1CqkBUJtdmogukq0wPOtdIVWyptfwB "Julia 0.6 – Try It Online")
Nothing too groundbreaking. This is a function that accepts an array and an integer and returns an integer. It just uses the basic algorithm. It would be a whole lot shorter if `min` and `max` didn't require splatting arrays into arguments.
We get each overlapping subarray, take the max, and take the min of the result.
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), 6 bytes
```
YCX>X<
```
[**Try it online!**](http://matl.tryitonline.net/#code=WUNYPlg8&input=WzUgNDIgMyAyM10KMw)
```
YC    % Implicitly input array and number. Build a matrix with columns formed
      % by sliding blocks of the array with size given by the number
X>    % Maximum of each column
X<    % Minimum of all maxima. Implicitly display
```
[Answer]
# Python 3, 55 bytes.
```
lambda x,n:min(max(x[b:b+n])for b in range(len(x)-n+1))
```
Test cases:
```
assert f([1, 5, 3, 4], 2) == 4
assert f([1, 2, 3, 4, 5], 3) == 3
assert f([1, 1, 1, 1, 5], 4) == 1
assert f([5, 42, 3, 23], 3 ) == 42
```
[Answer]
## Python 2, 50 bytes
```
f=lambda l,n:l[n-1:]and min(max(l[:n]),f(l[1:],n))
```
Recursively computes the minimum of two things: the max of the first `n` entries, and the recursive function on the list with first element removed. For a base case of the list having fewer than `n` elements, gives the empty list, which serves as infinity because Python 2 puts lists as greater than numbers.
[Answer]
# Mathematica, 23 bytes
```
Min@BlockMap[Max,##,1]&
```
**Test case**
```
%[{1,2,3,4,5},3]
(* 3 *)
```
[Answer]
# J, 9 bytes
```
[:<./>./\
```
Similar to the APL answer. `>./\` applies `>./` (maximum) to the (left arg)-subsets of the right arg. Then, `<./` finds the minimum of that, since it's capped with `[:`.
## Test cases
```
   f =: [:<./>./\
   2 f 1 5 3 4
4
   3 f 1 2 3 4 5
3
   3 f 1 1 1 1 5
1
   3 f 5 42 3 23
42
```
[Answer]
# [Factor](https://factorcode.org/), 34 bytes
```
[ clump [ supremum ] map infimum ]
```
[Try it online!](https://tio.run/##Vc49DsIwDAXgvad4FwCJNl3gAIiFBTFVDFHklojmhzgZUNWzl7RlKH6TP9myW6miC9P9drmej@iCS17bDkzvRFYRQzI7xXhRsNTDB4rx44O2EaeiGArkGnIOqFFBYESJcaPlonX26s/XzC42XkPMC2X1mx@nBqpPxqMBp3zcJIMHjPTQttVLl0f22ZQz3jGt/@5Iquf0BQ "Factor – Try It Online")
## Explanation
```
                  ! { 1 5 3 4 } 2
clump             ! { { 1 5 } { 5 3 } { 3 4 } }
[ supremum ] map  ! { 5 5 4 }
infimum           ! 4
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ŒIù€àß
```
[Try it online](https://tio.run/##yy9OTMpM/f//6CTPwzsfNa05vODw/P//ow11THWMdUxiuYwA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWVC6P@jkyIO73zUtObwgsPz/@v8j46ONtQx1THWMYnVMYrVUQBxjUBcHdNYHWOoAAQCBUzAAqY6JiAlRsYgFbEA).
**Explanation:**
```
Œ       # Get all sublists of the (implicit) input-list
 Iù     # Only keep those of a size equal to the second input
   €à   # Get the maximum of each inner list
     ß  # Pop and push the minimum of that
        # (after which the result is output implicitly)
```
[Answer]
# Java 8, ~~128~~ ~~126~~ ~~124~~ 105 bytes
```
a->n->{int r=0,m,j,t,i=-1;for(;i++<a.length-n;r=r<1|m<r?m:r)for(m=j=0;j<n;m=t>m?t:m)t=a[i+j++];return r;}
```
[Try it online.](https://tio.run/##lY89b4NADIZ3foVHEMcpH7DkOLJV6tApY8RwTSC5K2fQYVJFKb@dQotaqUMl5MXS68f2Y9RNReb8Npwq1bbwojQ@PICWFOkTmDHlHemKlx2eSNfIn@Ym1UjHnP078oxUXArHYG6yDEqQg4oyjLLHuACcXDHLDCOmZbQWZe18ocMwVbwq8ELXCIWTLl1/2NTt7c4F04SVRq6ESVFYSZnd084GJNVRhyYMc@EK6hyCE/0gvNGl6V6r0WVWutX6DHbU9A/kNF6OOahgUgY43FsqLK874s0YUYV@yVXTVHcfi3f4En6sWcK2LO6DOdkEgVhCbyaaJT/8diH/Xb98vIhPWDw9sNn@vd97/fAJ)
**Explanation:**
```
a->n->{                    // Method with Integer-array & Integer as parameters
                           // and Integer return-type
  int r=0,                 //  Result-integer, starting at 0
      m,                   //  Max-integer, uninitialized
      j,t,                 //  Temp integers
  i=-1;for(;i++<a.length-n //  Loop `i` in the range (-1,length-n]:
           ;               //    After every iteration:
            r=             //     Change the result to:
              r<1          //      If the result is 0 (first iteration),
              |m<r?        //      or the max is smaller than the result:
                m          //       Change the result to this max
              :            //      Else:
               r)          //       Keep it unchanged
    for(m=                 //   Reset the max to 0
        j=0;j<n            //   Inner loop `j` in the range [0,n):
        ;                  //     After every iteration:
         m=t>m?t:m)        //      Set `m` to the max of `m` and `t`
      t=a[i+j++];          //    Set `t` to the `i+j`'th item of the array
  return r;}               //  After the nested loops, return the result
```
[Answer]
# [Rust](https://www.rust-lang.org/), 46 bytes
```
|s,n|s.windows(n).map(|a|a.iter().max()).min()
```
[Try it online!](https://tio.run/##bY7LasMwEEX3@ooJCDNDVEP82CSNl9l20aUxRqQKiNhyKsmk1Pa3u1b6WiQSzGU0586V7Z2fTwZaqQ3SAM5Lr49w2J4MRmWfJpXonf5U9FS8XLzuzPOPRMusKGAP8@iEGV181eatuzo0FLfygqMcZay9shj6D6RFQsS8Y6082q62faPcagk@q9or5wfkWHLkctsEm2xoXQlufjtu/99pXwwcpXPK@lq9r/Cw/DVYSdw8JF67VuGtRNwS0Y7W08T@slYDKzeQQwpZJSCBBycLRBIIyBcmvSfSQHzfQGT3xIaVOWRhSZI@3JElbGLT/AU "Rust – Try It Online")
Takes in a `&[u32]` and returns an `Option<Option<&u32>>`. The result will be `Some(Some(&minimax))` so long as valid input is supplied.
[Answer]
# [Burlesque](https://github.com/FMNSSun/Burlesque), 7 bytes
```
CO)>]<]
```
[Try it online!](https://tio.run/##SyotykktLixN/V9dkPrf2V/TLtYm9n9pQW15TnHG/2pDBVMFYwWTWgUjLiDbCMRWMK1VMAbxIBDIM@GqNlUwAUkaGQPlAA "Burlesque – Try It Online")
```
CO  # Sliding window length N
)>] # Map max of block
<]  # Min of result
```
[Answer]
# [Julia 1.0](http://julialang.org/), 48 bytes
```
x\n=minimum(n:length(x).|>i->max(x[i-n+1:i]...))
```
[Try it online!](https://tio.run/##bcw7DoMwEATQnlOsRGMrYAlsGiS4QU4AFEY4yUb2BvGJXOTuDhYtM80UT/PeLerCh@B7ahwSut0xqq2h5/Zinotfi3nrtGe@w5xuRY2DEILz8PgsYJEMIMFi9BT3yngCR3Q2QgPmqy27m02LWS@rYVHwE8wL0maJ6X7kiaEpdAVUIEENGZRwkVQlBykjgepA8oLISM5Goi5IkXQVqHhTysuXVJV/ "Julia 1.0 – Try It Online")
based on [Alex A.](https://codegolf.stackexchange.com/users/20469)'s [answer](https://codegolf.stackexchange.com/a/73214/98541)
[Answer]
# JavaScript (ES6), 70 bytes
```
x=>n=>-M(...x.slice(n-1).map((_,i)=>-M(...x.slice(i,i+n)))),M=Math.max
```
Using [currying](https://codegolf.meta.stackexchange.com/a/8427/42091), this function saves 2 bytes from the previous answer.
## Demo
```
f=x=>n=>-M(...x.slice(n-1).map((_,i)=>-M(...x.slice(i,i+n)))),M=Math.max
a=[[[1,5,3,4],2,4],[[1,2,3,4,5],3,3],[[1,1,1,1,5],4,1],[[5,42,3,23],3,42]]
document.write(`<pre>${a.map(r=>`${f(r[0])(r[1])==r[2]?'PASS':'FAIL'} ${r[1]}=>${r[2]}`).join`\n`}`)
```
[Answer]
## Racket 84 bytes
```
(λ(l i)(apply min(for/list((j(-(length l)(- i 1))))(apply max(take(drop l j) i)))))
```
Ungolfed:
```
(define f
  (λ (l i)
    (apply min (for/list ((j (- (length l)
                                (- i 1))))
                 (apply max (take (drop l j) i))
                 ))))
```
Testing: 
```
(f '[1 5 3 4]  2)
(f '[1 2 3 4 5] 3)
(f '[5 42 3 23] 3)
```
Output:
```
4
3
42
```
[Answer]
## Clojure, 51 bytes
```
#(apply min(for[p(partition %2 1 %)](apply max p)))
```
[Answer]
# SmileBASIC, 68 bytes
```
M=MAX(X)DIM T[N]FOR I=.TO LEN(X)-N-1COPY T,X,I,N
M=MIN(M,MAX(T))NEXT
```
Nothing special here. Inputs are `X[]` and `N`
[Answer]
# T-SQL, 131 bytes
```
SELECT top 1max(iif(a<c,c,a))FROM x y
CROSS APPLY(SELECT a c FROM x WHERE y.b<b and b<y.b+@)z
GROUP BY b
HAVING-@=~sum(1)ORDER BY 1
```
**[Try it online](https://dbfiddle.uk/?rdbms=sqlserver_2019&fiddle=0f7bbe3af379290485c5f3281d7532d4)**
[Answer]
# [R](https://www.r-project.org/), 64 bytes
```
function(x,n)min(apply(matrix(x,l<-sum(x|1)+1,n)[n:l-n,],1,max))
```
[Try it online!](https://tio.run/##DcpLCoAgEADQq7ScoXFhn014k2ghgiDoJKYwQXc3t49Xup@M6r6xq@FmEGJMgcHmHF9ItpYgA6NRT0sgn8ZZj3LyERXTRZqSFcTuwYGmnVbakBbsPw "R – Try It Online")
Answer without using `zoo`.
]