careercup / CtCI-6th-Edition

Cracking the Coding Interview 6th Ed. Solutions
11.33k stars 4.41k forks source link

Wrong code to push in the stack. #253

Open Ritabrata95 opened 8 months ago

Ritabrata95 commented 8 months ago

https://github.com/careercup/CtCI-6th-Edition/blob/59018cfcb90292209275db1c4b3ed306d4b07d7f/Java/Ch%2003.%20Stacks%20and%20Queues/Q3_01_Three_in_One/FixedMultiStack.java#L28

I think the correct code would be "values[indexOfTop(stackNum) + 1] = value;" because the existing code is overriding the top element instead of adding a new element in the top of the stack.