Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Yan Pomanitskiy (Pliant GmbH)
Creating a string part uses FIFO instead of LIFO

Yan Pomanitskiy (Pliant GmbH)

Feb 7, 2024

  • The stack is processed in LIFO (Last-In-First-Out) order. Each component is popped and appended to the start of the result string, preceded by "/".

This is a bit wrong.

The stack contains [a, b, c]. Using LIFO will create a string: /c/b/a

It should be noted that for-each uses internal array-based representation.

5

0

Comments
Comments
 Michal
Michal2 years ago

Agree. Didn't know traversing stack bottom-to-top was possible.

tai
tai a year ago

I just made a second stack to reverse the first one 😅

On this page