Nothing Smaller To The Left

For each element, report the nearest element to its left that is strictly smaller, or a dash when none exists. The algorithm scans left to right, pops while the stack top is at least the current value, reads the answer off the top, then pushes the current value.

Array: 1 3 4 2 5 3 4 2

after index 0 1 2 3 4 5 6 7
stack, bottom to top 1 1 3 1 3 4 1 2 1 2 5 1 2 3 ? ?

What is the full output?

A

- 2 2 - 3 2 2 -

B

- 1 3 1 2 2 3 1

C

- 1 3 1 2 2 3 2

D

- 1 1 1 1 1 1 1