Skip to main content
added 309 characters in body
Source Link
Cinaski
  • 2.3k
  • 1
  • 8
  • 17

MATL, 1212 11 bytes

0i:iY"hYs1GiY"Ys0h1G)

Try it online!Try it online!

Both n and k are 1is 0-indexed. Takes input in reverse order.

Saved 1 byte thanks to @Giuseppe

MATL, 12 bytes

0i:iY"hYs1G)

Try it online!

Both n and k are 1-indexed. Takes input in reverse order.

MATL, 12 11 bytes

:iY"Ys0h1G)

Try it online!

k is 0-indexed. Takes input in reverse order.

Saved 1 byte thanks to @Giuseppe

Source Link
Cinaski
  • 2.3k
  • 1
  • 8
  • 17

MATL, 12 bytes

0i:iY"hYs1G)

Try it online!

Both n and k are 1-indexed. Takes input in reverse order.