Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
3 deleted 50 characters in body
source | link

JavaScript, 40 bytes

Naïve first pass as I run out the door for lunch. Outputs in reverse order.

a=>a.map(x=>x?o.push(x):o.pop(),o=[])&&o

Try it online

1 byte saved thanks to Herman L.

JavaScript, 40 bytes

Naïve first pass as I run out the door for lunch. Outputs in reverse order.

a=>a.map(x=>x?o.push(x):o.pop(),o=[])&&o

Try it online

1 byte saved thanks to Herman L.

JavaScript, 40 bytes

Outputs in reverse order.

a=>a.map(x=>x?o.push(x):o.pop(),o=[])&&o

Try it online

1 byte saved thanks to Herman L.

2 added 128 characters in body
source | link

JavaScript, 4140 bytes

Naïve first pass as I run out the door for lunch. Outputs in reverse order.

a=>a.map(x=>o[xx=>x?"push":"pop"]o.push(x):o.pop(),o=[])&&o

Try it onlineTry it online

1 byte saved thanks to Herman L.

JavaScript, 41 bytes

Naïve first pass as I run out the door for lunch. Outputs in reverse order.

a=>a.map(x=>o[x?"push":"pop"](x),o=[])&&o

Try it online

JavaScript, 40 bytes

Naïve first pass as I run out the door for lunch. Outputs in reverse order.

a=>a.map(x=>x?o.push(x):o.pop(),o=[])&&o

Try it online

1 byte saved thanks to Herman L.

1
source | link

JavaScript, 41 bytes

Naïve first pass as I run out the door for lunch. Outputs in reverse order.

a=>a.map(x=>o[x?"push":"pop"](x),o=[])&&o

Try it online