Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Algorithm and implementation don't match

reagankm

May 17, 2024

The solution code doesn't match the algorithm and diagram. The solution code is perhaps a better implementation, but you ought to change something so these match.

The algorithm and diagram say that at the end you pop the elements from the stack (which gives you the string in the wrong order), and then you reverse the string.

The code doesn't pop elements from the stack, instead it accesses elements in a for loop so they're already in the correct order.

1

0

Comments
Comments

On this page