Skip to main content
1 of 3
LukStorms
  • 1.8k
  • 1
  • 12
  • 11

#Perl 5, (29 Bytes+2) = 31

A regex-less solution.

map{print$i=$_.' ',if$_>$i}@F

Test

Note that the @F array is filled because the -a switch is used.

$ echo 1 2 5 4 3 7  |perl -na -e 'map{print$i=$_.' ',if$_>$i}@F'
1 2 5 7
LukStorms
  • 1.8k
  • 1
  • 12
  • 11