Running second maximum of a list

Husk, 9 7 bytes

Saved a byte or two thanks to @Zgarb

mȯ→hOtḣ

Returns 0 for the first "second maximum"

Explaination

         -- implicit input, e.g          [1,5,3,6]
      ḣ  -- prefixes                     [[],[1],[1,5],[1,5,3],[1,5,3,6]]
     t   -- remove the first element     [[1],[1,5],[1,5,3],[1,5,3,6]]
mȯ       -- map the composition of 3 functions
    O    --   sort                       [[1],[1,5],[1,3,5],[1,3,5,6]]
   h     --   drop the last element      [[],[1],[1,3],[1,3,5]
  →      --   return the last element    [0,1,3,5]
         -- implicit output

Try it online!


05AB1E, 5 bytes

ηεà\à

Try it online!

Returns [] (arbitrary value) for first.


Python 2, 54 bytes

lambda x:[sorted(x[:i])[-2]for i in range(2,1+len(x))]

Try it online!